This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In this post, I am sharing a T-SQL script for renaming multiple tables to a SQL Server Database.
Recently, I was doing test migration for more than 100 tables. I planned to rename those tables before migration so later I can rollback those tables.
SQL Server: Script to rename Database Name, Table Name, Column Name
I used below script for renaming multiple tables of a database where I am adding “_backup” in the table name.
1 2 3 4 5 6 7 |
DECLARE @SQL NVARCHAR(max)='' SELECT @SQL += 'exec sp_rename ' + NAME + ',' + NAME + '_backup ' FROM sys.tables WHERE NAME IN ( 'table_one', 'table_two', 'table_three') EXEC sp_executesql @SQL |
Leave a Reply