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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 SP_RENAME Issue

Author  Topic 

EvilTadpole
Starting Member

9 Posts

Posted - 2005-07-25 : 17:52:57


I'm trying to use the SP_Rename storeprocedure to create a copy every friday. I'm trying to do the following

EXEC SP_RENAME 'Table1', 'Table1_' + convert(char,getdate(),112)

I keep getting an error saying 'Line 1: Incorrect syntax near '+'.'

I need to be able to attach the date at the end of the table. Anyone have any ideas?

nosepicker
Constraint Violating Yak Guru

366 Posts

Posted - 2005-07-25 : 18:25:53
declare @newname varchar(50)
set @newname = 'Table1_' + convert(char(8), getdate(), 112)

exec sp_rename 'Table1', @newname
Go to Top of Page

sql_noob
Starting Member

9 Posts

Posted - 2008-01-08 : 14:38:20
thank you

the magic of search

i want to archive some tables from different databases every month to one archive db and this is exactly what i've been trying to do after the copy
Go to Top of Page
   

- Advertisement -