Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

sp_rename Expand / Collapse
Author
Message
Posted Sunday, February 17, 2013 5:57 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 9:55 AM
Points: 1,877, Visits: 1,445
Hi All,

I need to use sp_rename - http://msdn.microsoft.com/en-us/library/ms188351.aspx
I need to use it for tables in the following way:
For an existing "table_name" table i create "table_name_new" table. I copy all the data from "table_name" to "table_name_new". Then i drop "table_name" and rename "table_name_new" to "table_name". Finally i create the FKs and indexes with same definitions as they were in "table_name".

I know it could be problematic using sp_rename for some other objects like SPs, FNs ...

Has anyone experienced any problems with renaming a table in this way. Please share.
Can anyone confirm as save the usage of sp_rename, and/or suggest something additionally.

Thanks
IgorMi


Post #1420970
Posted Monday, February 18, 2013 3:13 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, May 16, 2013 11:06 PM
Points: 179, Visits: 380
you should first check the dependencies for the particular object
by sp_depends
or by sys.dm_sql_referencing_entities ('OBJECT', 'OBJECT');

then you can modify your object in a more appropriate way
Post #1421120
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse