By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,299 Members | 1,247 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,299 IT Pros & Developers. It's quick & easy.

Running SQL scripts programatically

P: 1
Hi there,

I'm just trying to find out which is the best way to programmatically 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.
Feb 15 '08 #1
Share this Question
Share on Google+
2 Replies


amitpatel66
Expert 100+
P: 2,367
Hi there,

I'm just trying to find out which is the best way to programmatically 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.
Feb 15 '08 #2

ck9663
Expert 2.5K+
P: 2,878
Then maybe you can try to run them as SPs and just use parameters as needed?

-- CK
Feb 15 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.