I'm trying to insert into a table 2 values one of which is an
exec master..xp_cmdshell @.command where I have assigned @.command with a value
this statement gives me the result into a 1 col. table fine:
insert into mytable99(col1) exec master..xp_cmdshell @.command
now what I want to do is put col2 in there as well!!
ie. insert into mytable99(col1,col2) values (exec master..xp_cmdshell @.command, '123')
I get a sytax error ... on the exec ??
Could anyone help re the proper way of doing this ... thanks in advancedid'nt know U could do something like this - sounds possibly clever
Syntax wise this command expects the optional parameter no_output after the comma
xp_cmdshell {'command_string'} [, no_output]
Your probably better off with with assigning each value to a local variable then inserting the contents of the variables into the table - something like
SET @.CmdShellOutput = exec master..xp_cmdshell @.command
SET @.StringNumber = '123'
insert into mytable99(col1,col2)
values (@.CmdShellOutput , @.StringNumber)
Sorry not had time to test this syntax but hopefully U get the picture.
GW
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment