Thread: MS SQL Command line insert
10-13-05, 20:25 #1Registered User
- Join Date
- Sep 2005
Unanswered: MS SQL Command line insert
I use a similar command below to insert into a temp table the result of a large command line call to an exectable with many parameters passed in the command of which the result passed back contains many items. I then parse the response string to get my results...
set @command = 'dir'
insert into tsverisign(response) exec master..xp_cmdshell @command
My question is our can I insert two values at the same time to this same table one of which is my "exec master..xp_cmdshell @command"
similar to insert into tables (field_a, feild_b) values ('1','2')
Something like (and I know this does not work):
insert into tsverisign(response,trans_id)
values (exec master..xp_cmdshell @command, '123')
Any help would be greatly appreciated .... PS I'm new to MS SQL 2000 and proper syntax etc. etc. so I need full example so I can try.
10-14-05, 08:45 #2Registered User
- Join Date
- May 2002
What you're trying to do is not possible (in any dbms). What you should do is to dump the result of @command into a staging table. Then insert it into the target table.
insert into staging(i)
exec master..xp_cmdshell @command
insert into target(i,j)
select i, @other_val