开发者

Dropping and recreating procedures (SQL Server)

I'm working with a product, that during upgrades drop's and recreates all of the existing procedures (basically just finding all of the proper proc's from the INFORMATION_SCHEMA and drops then) then re-creates all of the new ones. I believe the intent is to ensure all of the procedures are up to date.

The problem that I am currently running into, is that on a really slow customers database, the script that r开发者_如何转开发ecreates all of the procedures fails stating that the procedure already exists. It looks like for some reason or another, the database server has not caught up.

I have tried adding a DBCC FREEPROCCACHE in between the drops and the creates, but still to no avail. And ideas on how I can get this working?


Check if the proc belongs to a different schema than expexted.

Something like myaccount.MyProc if it is expected to be dbo.MyProc


As an aside to my answer, a possibly more robust way of doing this would be to have scripts for each sproc that does something like:

IF SPROC EXISTS
THEN
DROP IT
GO

CREATE SPROC
GO

This keeps each drop/creation as one item, and you can be more sure that the sproc is actually being deleted...

(Incidentally - is there any chance that your big deletion script is looking for everything in the dbo schema, and this database accidentally has a sproc created in another schema)?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜