在Visual Studio2008内部SQL Server中创建存储过程 [英] creating stored procedure in visual studio2008 internal sql server

查看:95
本文介绍了在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

推荐答案

SSMS不能解释批处理整个过程,但有两个单独的命令.

也许像这样:
The SSMS isn''t interpreting the batch as a whole procedure but two separate commands.

Perhaps like this:
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


似乎上述创建过程中还存在其他SQL语句.用GO语句将它们分开.
试试这个:
it seems like there are other SQL statements present above create procedure. Separate them with a GO statement.
Try this:
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中创建存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆