Re: Rename a view that has dependent views

From: Sebastian K. Zaklada (szaklada-dont-like-spam_at_skilledsoftware.com)
Date: 02/10/04


Date: Tue, 10 Feb 2004 18:45:20 +0100


> 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.

1) Renaming a view does not change the name of the view in the text of the
view's definition. To change the name of the view in the definition, modify
the view directly. sp_rename will simply alter the name of object in the
sysobjects system table, but will not alter its text in the syscomments
table.

2) If you have views like VTest1, VTest2 and VTest2 uses VTest1 in the
SELECT clause, the sp_rename will not change the SELECT code in the VTest1.
The same is true for other dependencies (UDFs, triggers...)

3) My advice is:

- script the view and all dependent objects with re-create statements
- perform a global search-and-replace to change the old view name to new
view name
- double check that it replaced only what you intended to replace
- run the script (it will re-create the view and all dependent objects)

sincerely,

--
Sebastian K. Zaklada
Skilled Software
http://www.skilledsoftware.com
This posting is provided "AS IS" with no warranties, and confers no rights.


Relevant Pages

  • Re: Starting & stopping services
    ... dependent services, then the dependent service must be stopped first. ... 22 Status - Invalid Service Account ... the script works fine without it, I was more curious what it was for, I'll ... When your script writes lines of text to StdOut then they will end up in ...
    (microsoft.public.scripting.vbscript)
  • error in php5 make install
    ... Turn off all options accept Apache module ... *** Error code 2 ... Script didn't even look for m4 dependent. ...
    (freebsd-questions)
  • Re: Generic Script - Indicating Success or Failure
    ... you should make the services dependent on the script ... script when not sucsesful --> the script would fail, ... a generic script resource in a cluster resource group. ...
    (microsoft.public.windows.server.clustering)
  • Re: Run a batch file or script after boot but before login?
    ... I think that Dave's idea probably will work, but it can also be dependent ... upon what exactly you want the script to do. ... How to Run a Batch File Before Logging on to Your Computer ... filter the ACL on the policy object so only the SBS can apply it. ...
    (microsoft.public.backoffice.smallbiz2000)
  • Re: login script question
    ... | How would you script a login to run something dependent ... | upon whether or not the pagefile file is found (i.e. run ...
    (microsoft.public.win2000.general)