SQL 语法错误 CREATE PROCEDURE AS EXTERNAL
问题:如果我将 IF not存在添加到创建过程作为外部名称语句,我会收到语法错误...为什么? 如果我单独运行它们,这两个语句都可以正常工作......
IF NOT EXISTS
(
SELECT * FROM sys.objects
WHERE object_id = OBJECT_ID(N'PriceSum')
AND type in (N'P', N'PC')
)
CREATE PROCEDURE PriceSum(@sum int OUTPUT)
AS EXTERNAL NAME MyFirstUdp.[SQL_CLRdll.MySQLclass].PriceSum
Question: If I add IF not exists to a create procedure as external name statement, I get a syntax error... why?
Both statements work fine if I run them separately...
IF NOT EXISTS
(
SELECT * FROM sys.objects
WHERE object_id = OBJECT_ID(N'PriceSum')
AND type in (N'P', N'PC')
)
CREATE PROCEDURE PriceSum(@sum int OUTPUT)
AS EXTERNAL NAME MyFirstUdp.[SQL_CLRdll.MySQLclass].PriceSum
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因为 CREATE PROCEDURE 必须是批处理中的第一个语句。
要么先删除 proc,要么使用动态 SQL,
您也可以反转逻辑
because the CREATE PROCEDURE has to be the first statement in a batch.
either drop the proc first or use dynamic SQL
you can also reverse the logic
尝试一下
,我认为它不喜欢
CREATE PROCEDURE
之前和同一批次中的东西。Try
I don't think it likes stuff before
CREATE PROCEDURE
and in the same batch.