Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 syntax

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2011-12-14 : 05:10:03
In the below sql, the error is on the first + sign before @sql.
It says: Incorrect syntax near '+'.
EXEC master..xp_cmdshell '''DTExec /f ' + @sql + ''

the result show do the following:
EXEC master..xp_cmdshell
'DTExec /f "D:\..."'

Do you see what I am doing wrong please?
Thanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-14 : 05:11:11
this is enough

EXEC master..xp_cmdshell 'DTExec /f ' + @sql + '...'



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2011-12-14 : 05:18:04
I have this but still the same error.
EXEC master..xp_cmdshell 'DTExec /f ' + @sql + ''
Not sure what you mean by '...'
Note that @sql is declared as nvarchar(1000)
The @sql is set to something like "D:\path\..."
Do you see the issue please?
Thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-14 : 05:19:06
show the full command

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2011-12-14 : 05:37:56
Solved by doing the following:
set @param = 'DTExec /f ' + @sql
EXEC master..xp_cmdshell @param

Thank you
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-14 : 05:49:51
k

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -