Wednesday, June 13, 2007

how to rename tables

select ' exec sp_rename '''+ name + ''' , ''zOLD_'+name +'''' from sys.objects where type_desc = 'user_table' and name not like 'zold%' order by [name]

here
name - actual table name
changed name will be zOLD_[TableName]

selected from sys.tables, alternatively u can select it from sys table

execute this query and copy the result into new Query analyser

and here is script that will do the disaster.


thanks
Pradeep

No comments: