Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
paradise_wolf
Starting Member
32 Posts |
Posted - 2007-04-27 : 20:38:44
|
| I have two questions:1) Is it possible to rename a SQL table –or- copy the content of a table into a new table ?2) How to replace the renamed or replaced table name inside the code of ALL Stored Procedures that references it ? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-04-27 : 20:56:09
|
1) yes2) you have to edit the stored procedure one by one. If you have your stored procedure code in text file, just use any editor open it and do a FIND and REPLACE. If you do not have the stored procedure in files which you should, you can use Enterprise Manager to script out the stored procedure to file. KH |
 |
|
|
dinakar
Master Smack Fu Yak Hacker
2507 Posts |
Posted - 2007-04-27 : 20:57:16
|
| use sp_rename to rename any objects.to copy the content of one table into another, there are multiple ways to do it. you can do a SELECT * INTO NewTable FROM OldTable. You will have to add indexes, PK/FK's manually. if the data is huge, you can use BCP utility of DTS wizard.You'd have to manually find all the procs that reference the table and change them yourself.to find procs thar reference a table you can query as:SELECT ProcNAme = objecT_name(id), * from syscomments where text like '%yourtable%'Dinakar NethiSQL Server MVP************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |
 |
|
|
paradise_wolf
Starting Member
32 Posts |
Posted - 2007-04-28 : 05:00:43
|
| Thank you very much, dinakar. |
 |
|
|
|
|
|