I have declared and set DOS statements within a procedure, but when I
attempt execute xp_cmdshell using the variable the statement errors out.
(See sample code below)
--start TSQL
declare @dos_statement varchar(32)
set @dos_statement = 'mkdir c:\Test\'
xp_cmdshell @dos_statement
--end TSQL
error is:
Server: Msg 170, Level 15, State 1, Line 4
Line 4: Incorrect syntax near 'xp_cmdshell'.
EXEC master..xp_cmdshell @dos_statement
--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"William Enloe" <willia...@domail.maricopa.edu> wrote in message
news:3FFEE7A8...@domail.maricopa.edu...
Cripes, my English professor would have a field day on that one.
EXEC name
;)
"Aaron Bertrand - MVP" <aa...@TRASHaspfaq.com> wrote in message
news:u$rKGpt1D...@tk2msftngp13.phx.gbl...
EXEC MASTER..xp_cmdshell @dos_statement
exec xp_cmdshell @dos_statemen
----- William Enloe wrote: -----
Does anyone know how to set up xp_cmdshell to use variable names within
a procedure?
I have declared and set DOS statements within a procedure, but when I
attempt execute xp_cmdshell using the variable the statement errors out.
(See sample code below)
--start TSQL
declare @dos_statement varchar(32)
set @dos_statement = 'mkdir c:\Test\'
xp_cmdshell @dos_statemen
Thanks
I can certainly imagine worse places for it to be. :-)