I would like to set a variable that is a sql statement, but the syntax about the quotes is so confusing to me, I cannot make it right:
What I have is this:
SET @sqlcmd = 'BACKUP DATABASE '+@dbname+' TO DISK = ''H:\Preupgrade\ Backups\'+@dbname+'_'+@filedate +' WITH NOFORMAT, NOINIT,' +
' NAME = '''+@dbname+@filedate+''', SKIP, REWIND, NOUNLOAD, STATS = 10'
then EXEC sp_executesql @sqlcmd
How can I use single quotes in statement like above?