I am trying to run a SQL command but I am getting error message of Not a Valid Identifier.
If I am using this command,
EXEC xp_cmdshell N'mkdir C:\Users\PC\Desktop\Backup\1042012'
GO
then this command works properly
But, if I am using this command
DECLARE @CurrentDate varchar(50)
DECLARE @Path varchar(200)
DECLARE @Command varchar(200)
SET @CurrentDate = GETDATE()
SET @Path = N'C:\Users\PC\Desktop\Backup'
SET @Command = N'xp_cmdshell " ' + 'MKDIR' + ' '+ @Path + '\' + @CurrentDate + '" '
EXEC @Command
GO
I am getting that error message. Is something to do with declaring a string properly or not.