I'm trying to rename a table using sp_rename
but I am getting the following error when executing the query:
DECLARE @DateValue INT
SET @DateValue = CONVERT(VARCHAR(8), GETDATE()-1, 112)
DECLARE @ArchiveTableName VARCHAR(255)
SET @ArchiveTableName = 'dbo.tblProductPipeline_'+ CAST(@DateValue AS VARCHAR)
EXEC SP_RENAME 'dbo.tblProductPipeline_Daily', @ArchiveTableName
Msg 15225, Level 11, State 1, Procedure sp_rename, Line 338
No item by the name of 'dbo.tblProductPipeline_Daily' could be found in the current database 'Nexus', given that @itemtype was input as '(null)'.
Can anyone please help me with my understanding of what's going wrong?
Thank you!