Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2004
    Location
    United Kingdom
    Posts
    6

    Lightbulb Unanswered: reading sql from a disk file

    It's probably a really easy thing to do, but I can't find out how to do it, so hopefully somebody can spare the time to help.

    I want to read in T-SQL contained in a file held on disk and execute it in a stored procedure.

    Anybody know how to get the contents of the text file into a variable so I can exec it ?

    Thanks for your time.

  2. #2
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    you can probably use osql or isql for the same.
    Get yourself a copy of the The Holy Book

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

  3. #3
    Join Date
    Feb 2004
    Location
    United Kingdom
    Posts
    6
    Is that possible from a stored procedure ?

  4. #4
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    example

    exec xp_cmdshell 'osql .....' etc
    Get yourself a copy of the The Holy Book

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

  5. #5
    Join Date
    Feb 2004
    Location
    United Kingdom
    Posts
    6
    Thank you for taking the time to answer.

    I presume using this method any sql executed from the call to xp_cmdshell will be in a different transaction. If this is the case, any idea how it can be called in the same one as the procedure ?

Posting Permissions

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