question

jyoukhanis avatar image
jyoukhanis asked

exec master.dbo.xp_cmdshell variable error

PLease help. What is wrong with my TSQL? It states The filename, directory name, or volume label syntax is incorrect. DECLARE @databasename varchar (200) DECLARE @cmd varchar (300) DECLARE @pathfile varchar (150) DECLARE @destinationfile varchar (150) SET @destinationfile='\\SHDVNFDBV1\shared-backup''' SET @PATHFILE='''copy"G:\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\Pedialink\' SET @databasename='Pedialink_Full_' set @cmd=@pathfile+@databasename + (SELECT CONVERT(char(10), GetDate()-1,126))+'.ls"'+SPACE(1) + @destinationfile select @cmd exec master.dbo.xp_cmdshell @cmd OUTPUT The filename, directory name, or volume label syntax is incorrect.
sql-serverxp_cmdshell
3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

What you get from the `select @cmd` statement - is that correct?
2 Likes 2 ·
It was a permission issue. thank you.
0 Likes 0 ·
Could you post the solution so that others who have the problem can also solve it?
0 Likes 0 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.