Results 1 to 2 of 2
  1. #1
    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.

  2. #2
    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
    from staging

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts