-- 删除表和过程
/**
drop table tb_Server
drop procedure sp_add
**/
/**
CREATE TABLE tb_Server(
id int identity(1,1) PRIMARY KEY,
s_wmsccp nvarchar(200),
s_ip nvarchar(200)
)
**/
Create PROC sp_add
@u_wmsccp nvarchar(50),
@s_ip nvarchar(50)
AS
declare @cid varchar(300) -- 可以声明多个变量。
select @cid=count(id) from tb_server where s_ip=@s_ip
if @s_ip<>''
begin
IF @cid='0'--当没有记录时
BEGIN
Insert INTO tb_Server(s_wmsccp, s_ip)VALUES (@u_wmsccp, @s_ip)
END
ELSE--当有记录时
BEGIN
Update tb_Server SET s_wmsccp = @u_wmsccp Where (s_ip = @s_ip)
END
end