Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2002
    Location
    Switzerland
    Posts
    524

    Unanswered: output of a stored proc into a table

    Want to obtain the outpur of a xp_cmdshell (or any other procedure call) command to a table. Is it possible ?
    F. Celaia
    DBA Sybase/DB2/Oracle/MS-SQL

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Sure....

    Code:
    USE Northwind
    GO
    
    SET NOCOUNT ON
    CREATE TABLE myTable99(Col1 varchar(8000))
    GO
    
    INSERT INTO myTable99(Col1)
    EXEC master..xp_cmdshell 'Dir C:\*.*'
    
    SELECT * FROM myTable99
    GO
    
    DROP TABLE myTable99
    SET NOCOUNT OFF
    GO
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Nov 2002
    Location
    Switzerland
    Posts
    524
    so easy... thank you brett
    F. Celaia
    DBA Sybase/DB2/Oracle/MS-SQL

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Quote Originally Posted by fadace
    so easy... thank you brett

    If it wasn't, do you think I'd get it?



    Is it Friday yet?

    OK, I'll settle for 5:00.....

    Damn...not yet...

    Oh, and to make this post have some actual value (ok, so you're gonna ask me, why start now...)

    Spocs that return multiple columns will have to have a table that matchs....and any sproc that returns multiple results sets will fail...never figured that one out....
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

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

    Lightbulb how to use select into instead of insert into

    hai...

    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

  6. #6
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    You can't...just predefine the table like I posted.
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

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

    Talking Could you explain

    thnks Brett..for your reply

    If you don't mind, could you kindly explain me why we cannot use 'SELECT INTO' while we can use 'INSERT INTO' statement for storing
    the result of the Stored Procdeure in a table.

    sorry for troubling you..

    with regards
    Sudar

Posting Permissions

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