Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2004
    Location
    Mars
    Posts
    137

    Exclamation Unanswered: Store the result of xp_cmdshell in a table

    hai..

    is it possible to store the result the following statement in a table

    execute master..xp_cmdshell 'dir'

    when i execute this in QA i get the result. but i want to store it in a table

    thnks in advance

    with regards
    Sudar

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Yes

    -PatP

  3. #3
    Join Date
    Jul 2004
    Location
    Mars
    Posts
    137

    Thumbs up thnks

    thnks pat the post u showed really soleved my problem

    with regards
    Sudar

  4. #4
    Join Date
    Jul 2004
    Location
    Mars
    Posts
    137

    Lightbulb how to use select into

    hai patt.

    this question just out of my curiosity. how can i use select into statement to insert the output of the stored procedure (xp_cmdshell) into a table.

    with regards
    Sudar

  5. #5
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Just use Brett's example. I think it does exactly what you want, doesn't it?

    -PatP

  6. #6
    Join Date
    Jul 2004
    Location
    Mars
    Posts
    137

    Talking Could you explain

    hai pat..

    ya, my problem is solved. but the solution has provoked my curiosity.

    if possible could you take up trouble in explaining me why we cannot use 'SELECT INTO' but can use "INSERT INTO' to store the
    result of a stored procdure in a table..

    sorry for the trouble caused.

    with regards
    Sudar

  7. #7
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    That's easy, the SELECT INTO syntax doesn't support the EXECUTE clause!

    -PatP

    P.S. Yes, for you wiseacres in the peanut gallery, there is a way to open a query to do this, but it is both ugly and unsafe. There is a reason that INSERT INTO supports this while SELECT INTO does not!

Posting Permissions

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