Running SQL scripts programatically

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Carter35
    New Member
    • Feb 2008
    • 1

    Running SQL scripts programatically

    Hi there,

    I'm just trying to find out which is the best way to programmaticall y run an sql script. In our system we have a mechanism of creating a new database for any new clients. We have scripted all of the tables/stored procedures/indexes etc into an SQL file.

    Once we have created a new database, we need to be able to run our script against that database so that all of the database objects are created automatically. Obviously the script is quite large and is not something you can just load into an SqlCommand object!

    Thanks for any help on this
    Paul.
  • amitpatel66
    Recognized Expert Top Contributor
    • Mar 2007
    • 2358

    #2
    Originally posted by Carter35
    Hi there,

    I'm just trying to find out which is the best way to programmaticall y run an sql script. In our system we have a mechanism of creating a new database for any new clients. We have scripted all of the tables/stored procedures/indexes etc into an SQL file.

    Once we have created a new database, we need to be able to run our script against that database so that all of the database objects are created automatically. Obviously the script is quite large and is not something you can just load into an SqlCommand object!

    Thanks for any help on this
    Paul.
    Why dont you break down the scripts in to different modules say one each for tables,indexes, etc and run those sql script files seperately.

    Comment

    • ck9663
      Recognized Expert Specialist
      • Jun 2007
      • 2878

      #3
      Then maybe you can try to run them as SPs and just use parameters as needed?

      -- CK

      Comment

      Working...