Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How do I run an sql script using SQL-DMO?

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-07-23 : 08:57:11
Michael writes "I'm writing an msi installer to install my database.

I've created a custom action for the installer, written in C++, which uses SQL-DMO to connect to SQLServer and create a database.

I now want to run an SQL script to populate the database with tables, stored-proceedures, etc.

How do I run the script using SQL-DMO? I can see how to create a script with the GenerateSQL or Script methods but I can find a method that will run a script.

Thanks in advance,
Michael

PS. I feel I'm re-inventing the wheel here but haven't found any good resources that demonstrate installing a user database using MSI."

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-07-23 : 09:37:25
Take a look in Books Online under the SQL-DMO reference (Contents Tab, Building SQL Server Applications) There are several Execute methods (ExecuteImmediate, ExecuteWithResults, etc.) You can probably open the script file, read it into a string variable, and then pass it to an Execute method.

What about creating your user database and then include the data file(s) in the MSI package? You can then just attach the file as a new database.

Go to Top of Page
   

- Advertisement -