本文介绍了在Visual Studio2008内部SQL Server中创建存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在尝试通过查询在Visual Studio的内部sqlserver2005中创建存储过程






i am trying to create a stored procedure in my internal sqlserver2005 of visual studio by the query



create procedure usp_insert(@tower nvarchar(20),@floor nvarchar(20),@flatno nvarchar(20),@status nvarchar(20),@color nvarchar(20))
as
insert into booksta values(@tower,@floor,@flatno,@status,@color)





但出现错误

'CREATE/ALTER PROCEDURE'必须是查询批处理中的第一条语句.'我的查询是否有任何问题





but got a error

‘CREATE/ALTER PROCEDURE’ must be the first statement in a query batch.’ is there any problem with my query

推荐答案

create procedure usp_insert(@tower nvarchar(20),@floor nvarchar(20),@flatno nvarchar(20),@status nvarchar(20),@color nvarchar(20))
as
begin
   insert into booksta values(@tower,@floor,@flatno,@status,@color);
end;
go



另外,在运行该批处理时,编辑器应仅具有该批处理,否则您可以在执行批处理之前仅选择包含过程定义的行



Also the editor should have only that batch when yuo run it or you can select just the lines containing the procedure definition prior to executing the batch


create procedure usp_insert

@tower nvarchar(20),@floor nvarchar(20),@flatno nvarchar(20),@status nvarchar(20),@color nvarchar(20)

as
BEGIN

insert into booksta values(@tower,@floor,@flatno,@status,@color)
END


GO
create procedure usp_insert(
             @tower nvarchar(20)
            ,@floor nvarchar(20)
            ,@flatno nvarchar(20)
            ,@status nvarchar(20)
            ,@color nvarchar(20)
           )
as
SET NOCOUNT ON
insert into booksta values(@tower,@floor,@flatno,@status,@color)
GO


这篇关于在Visual Studio2008内部SQL Server中创建存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 18:28