USE [数据库]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[存储过程名称]
(
@name varchar(50),
@state int,
@capbility int,
@ip varchar(50),
@port int
)
AS
SET NOCOUNT ON;
BEGIN
declare @count int;
declare @id int;
--判断此服务器是否已经注册
select @count=COUNT(*) from serverlist where name =@name;
if(@count>0)--此服务器已经注册过
BEGIN
select "ERROR" = -100; --此服务器已经注册过
END else
BEGIN
insert into serverlist(name,[state],capbility,ip,port) values (@name,@state,@capbility,@ip,@port);select @@identity;
select @id;
END
END
USE [数据库]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[存储过程名称]
(
@name varchar(50),
@state int,
@capbility int,
@ip varchar(50),
@port int,
@id int
)
AS
SET NOCOUNT ON;
BEGIN
declare @count int;
declare @return int;
select @count=COUNT(*) from serverlist where name =@name and ID<>@id;
if(@count>0)
BEGIN
select "error"=-100;
end
begin
select @count=COUNT(*) from serverlist where id =@id
if(@count>0)
begin
update serverlist set name=@name,[state]=@state,capbility=@capbility,ip=@ip,port=@port where ID=@id;
set @return = 1;
end else
begin
set @return = 0;
end
end
select @return;
END