Cannot find the object “XXX” because it does not e

2019-06-15 14:26发布

I'm getting the following error when calling a stored procedure:

Cannot find the object "XXX" because it does not exist or you do not have permission.

I've checked the database and the SP is there with the correct permissions yet I'm still getting the error.

Any suggestions?

10条回答
姐就是有狂的资本
2楼-- · 2019-06-15 14:40

Even after adding 'GO' issue did not fixed for me. Then removed UPDATE STATISTICS [Table_name] statement Then my issue was fixed.

查看更多
神经病院院长
3楼-- · 2019-06-15 14:44

As well as other answers about schema/security etc:

  • do you have a DENY on it somewhere?
  • case sensitive object names and using "wrong" name?
  • wrong database context? eg OtherDB.dbo.Myproc
查看更多
Emotional °昔
4楼-- · 2019-06-15 14:49

I discovered that I had left off the "GO" word after "END" in my stored proc. Altering the Proc and adding back GO fixed this issue for me.

查看更多
贪生不怕死
5楼-- · 2019-06-15 14:49

Ok, here's what happened. There was a special character before the end of the SP so it was incomplete yet still valid, somehow.

So I could see the SP and see the permissions on it but I could not run it. So to solve the issue I had to copy the text out of SQL Management Studio and paste it into Notepad, then remove the special character, then copy and paste it back into SQL Management Studio and run the alter script.

Very strange how the character got there!

查看更多
▲ chillily
6楼-- · 2019-06-15 14:50

In Microsoft SQL server, selected the object in the object explorer that you want to work with, right-clicking it, then doing 'Script [object] as' can give you the script you need to perform an operation successfully without getting this error

查看更多
爷、活的狠高调
7楼-- · 2019-06-15 14:54

Similar to marked answer: The final line of my stored procedure was a line which granted permission to the stored procedure to run as the appropriate user - probably added there when I generated a script.

Removing that (or perhaps a hidden character attached) managed to fix it.

"XXX" was the name of the stored procedure I called, successfully (it made the desired change) but which gave me this error.

查看更多
登录 后发表回答