This doesn't need dynamic SQL, surely?For dd/mm/yyyy you need CONVERT(VARCHAR(10),GETDATE(),103))But I question the wisdom of putting "/" in table names ...There is also a syntax error in the original O/P question which would have prevented the SProc from compiling:set @Test02 = @Test02 +(CONVERT(VARCHAR(8),GETDATE()))
USE [Test]gocreate procedure [dbo].[renameTest]@Test varchar(50),@Test02 varchar(50)asset @Test02 = @Test02 +CONVERT(CHAR(10), GETDATE(), 103)PRINT 'Rename [' + COALESCE(@Test, 'NULL') + '] to [' + COALESCE(@Test02, 'NULL') + ']'IF NOT EXISTS (SELECT * FROM sys.tables WHERE [name] = @Test)BEGIN PRINT 'Table [' + COALESCE(@Test, 'NULL') + '] does not exist'ENDELSEBEGIN EXEC sp_rename @Test, @Test02ENDGOexec dbo.renameTest @Test='Test', @Test02='Test02'