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.
I used below script for renaming multiple tables of a database where I am adding “_backup” in the table name.
DECLARE @SQL NVARCHAR(max)=''
SELECT @SQL += 'exec sp_rename ' + NAME + ',' + NAME + '_backup '
WHERE NAME IN ( 'table_one', 'table_two', 'table_three')
EXEC sp_executesql @SQL