use a variable in the table name when renaming a table in SQL
问题 I am trying to rename a table in SQL Server 2008 R2 using the code below; declare @date varchar(8) set @date = convert( varchar(8), getdate(), 112) exec sp_rename 'LM_SM_Billing_and_Send_Data', 'LM_SM_Billing_and_Send_Data_@date' My intention is to rename the table with the current date appended. select convert( varchar(8), getdate(), 112) returns 20141219 but when I run the rename it names the table; LM_SM_Billing_and_Send_Data_@date instead of inserting the date I'm wondering if it is