SQL 2000 server: I want to standardize my naming scheme. I have views that
have other views dependent on them. I would like to rename some of these
without breaking the dependent views. It appears that sp_rename doesn't do
the trick.
Also, I'm confused about this comment in BOL: "Important After renaming
stored procedures and views, flush the procedure cache to ensure all
dependent stored procedures and views are recompiled."
I ran some tests, and it looks like sp_rename doesn't fix dependent views
that use a view that gets renamed, so what is this comment about?
Thanks. Any comments and suggestions will be appreciated.
David WalkerDavid,
No, sp_rename does not go through all the dependent procedures, views and tr
iggers and change the old view name to the new view name. You need to do tha
t yourself. If you are relying on the info in sysdepends, DO NOT. You can cr
eate a parent stored proced
ure that references a child/sub procedure before the child is created. SQL w
ill yell at you, but it will do it. You can create the child next and all wi
ll be fine.
You can search for objects that reference your old view name with:
SELECT OBJECT_NAME(id) FROM syscomments WHERE text LIKE '%oldviewname%'
in every database that may reference the old view.
The procedure cache is an area of the SQL Server memory that hold the execut
ion plans of stored procedures and views. You can just try your changes afte
r you implement them to see if it works, which you probably should. If some
erro occurs run DBCC FREEPR
OCCACHE.
Norman
No comments:
Post a Comment