Reading From an .sql File

  • Dear All,

    We have a requirement to read and execute .sql files, what is the best way of doing this. If possible could you please include code ?

    Thanks

    Julie

  • Hi Julie

    quote:


    We have a requirement to read and execute .sql files, what is the best way of doing this. If possible could you please include code ?


    how do you want to execute *.sql files?

    - via QA?

    - via T-SQL?

    - via OSQL?

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Thanks for your reply Frank.

    Using a vb application we want to create a file.

    This file contains the name of the .sql script to be run. The reason we are doing it like that is we want to create these on a nightly basis dynamically.

    So I assume we want to do it through T-SQL, as the file can them be picked up and activated by SQL Agent.

    Thanks

    Julie

  • quote:


    Using a vb application we want to create a file.

    This file contains the name of the .sql script to be run. The reason we are doing it like that is we want to create these on a nightly basis dynamically.

    So I assume we want to do it through T-SQL, as the file can them be picked up and activated by SQL Agent.


    What about using the OSQL utility within a stored procedure and call it with xp_cmdshell?

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Thanks Frank,

    And how would I do that ?

    Julie

  • quote:


    Thanks Frank,

    And how would I do that ?


    running an 'OSQL' search on this site will get you several intersting articles on using OSQL.

    If that's not enough, here's another one.

    http://www.sqlteam.com/item.asp?ItemID=744

    HTH

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply