无效的对象名称 - 存储过程
我正在通过 SSMS 在 SQL Server 中创建一个存储过程。
我已经编写了下面的存储过程,但是当我单击执行时,出现错误:
Msg 208,Level 16,State 6,Procedure NewQuestion,Line 11 对象名称“hgomez.NewQuestion”无效。
该表的所有权正确。 (hgomez.Questions)
USE [devworks_oscar]
GO
/****** Object: StoredProcedure [hgomez].[NewQuestion] Script Date: 10/23/2011 23:55:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [hgomez].[NewQuestion]
(
@QUESTIONNAME nvarchar(50),
@QUESTION_ID int OUTPUT
)
AS
/* SET NOCOUNT ON */
INSERT INTO [Questions] (QuestionText) VALUES (@QUESTIONNAME)
SET @QUESTION_ID = SCOPE_IDENTITY();
RETURN
提前致谢
I am creating a stored procedure in SQL Server via SSMS.
I have written the stored procedure below, however when I click execute it am given the error:
Msg 208, Level 16, State 6, Procedure NewQuestion, Line 11
Invalid object name 'hgomez.NewQuestion'.
the table is ownership is correct. (hgomez.Questions)
USE [devworks_oscar]
GO
/****** Object: StoredProcedure [hgomez].[NewQuestion] Script Date: 10/23/2011 23:55:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [hgomez].[NewQuestion]
(
@QUESTIONNAME nvarchar(50),
@QUESTION_ID int OUTPUT
)
AS
/* SET NOCOUNT ON */
INSERT INTO [Questions] (QuestionText) VALUES (@QUESTIONNAME)
SET @QUESTION_ID = SCOPE_IDENTITY();
RETURN
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我热衷于总是在 CREATE 语句前面明确检查是否存在,如果找到则将其删除。
这在权限方面可能会有点麻烦,因此其他人使用一种方法,他们创建一个存根方法只是为了立即
ALTER
它。I was a fan of always prepending my
CREATE
statements with an explicit check for existence and dropping if it was found.That can be a bit of hassle with regard to permissions so others use an approach wherein they create a stub method only to immediately
ALTER
it.该脚本尝试修改已经存在的过程;它不创建过程。
要创建过程,请使用
CREATE PROCEDURE
一次该过程存在,您可以使用
更改过程
This script tries to modify a procedure that already exists; it doesn't create the procedure.
To create the procedure use
CREATE PROCEDURE
Once the procedure exists, you can modify its definition by using
ALTER PROCEDURE
此解决方案 https://stackoverflow.com/a/26775310/2211788 解释
This solution https://stackoverflow.com/a/26775310/2211788 explained
当我打开两个 SSMS 实例并且我正在处理第一个打开的实例时,我就发生过这种情况。把它们都关闭了,重新打开,效果很好。
This happened to me once when I had two instances of SSMS open and I was working on the one I opened first. Closed them both down, reopened and it worked fine.