SQL script file and executing it

  • Thread starter Thread starter Jason
  • Start date Start date
J

Jason

Hi

I would like to create a .NET app that can receive an SQL script file as
input. it will take the script file and execute it on the database,
depending on what connection properties were entered by the user. best way?

Thanks
Jason
 
Hi

I would like to create a .NET app that can receive an SQL script file
as input. it will take the script file and execute it on the database,
depending on what connection properties were entered by the user. best
way?

Perhaps just read the text in and use SqlConnection.ExecuteNonQuery(). I
believe (not 100% on this) that it will handle multiple commands just fine
- no need to try to parse it out into separate commands.

-mdb
 
yeh, my initial thought was that. just thought maybe there was another way
that would be better?
 
ah hmmm

thanks Rasika. yeh i wanna do this :-) because this is for installation
purposes. it is done by the installation program and not by users, if thats
what you mean by your last point?

is there another easier way of deploying databases?

Thanks
Jason

Rasika said:
you can pass the sql string to a stored proc in MSSQL and use the exec
function to execute it. But do you really want to do that. People can drop
tables and play all srot of havoc with your DB?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top