Solved

Running SQL Scripts

Posted on 2001-07-18
7
988 Views
Last Modified: 2012-06-27
We are deploying an application based on MSDE.  I would like to store the database creation and generation details in SQL Script files.  This is an easy solution with SQL Server because I can simply run the scripts from the command line in the installation with the ISQL tool. (Note, I can't use an interactive solution because from the user's standpoint, the database create's itself on install).  The problem is now the solution is based on MSDE, which I am not entirely sure if ISQL (not ISQL/w) is deployed with MSDE.  If it is not, is it redistributable.  If it is not redistributable, does anybody have some good ADO code samples to read an SQL script that uses the same syntax as ISQL.  What I mean by syntax, is support for the "USE <DATABASENAME>" and Go command?
0
Comment
Question by:bequette
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 100 total points
ID: 6294026
If you have access to the SQL-DMO object libraries then you can use the following to achieve this:

 Dim sqlServer As SQLDMO.sqlServer
  Set sqlServer = New SQLDMO.sqlServer
  sqlServer.Connect "MySQLServer"
  sqlServer.Databases("MyDatabase").ExecuteImmediate Replace(strBatch,"GO",vbCRLF & "GO" & vbCRLF), SQLDMOExec_ContinueOnError
  sqlServer.DisConnect
  Set sqlServer = Nothing

Where strBatch contains the sql batch that you want to run.
0
 
LVL 2

Expert Comment

by:agriggs
ID: 6298286
I am pretty sure that SQL-DMO is installed when you install the SQL Client tools, like ISQL.

I think that you are on the right track when you say you need to read the scripts into an ADO project and then execute them.

GO is not a SQL keyword, it is an ISQL keyword that means just what it says.  So whenever you encounter a GO in your scripts, just execute your SQL string.
0
 
LVL 1

Expert Comment

by:lindr
ID: 6302125
You should be able to use the command line version (OSQL) which I think is shipped with MSDE.
0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 

Expert Comment

by:CleanupPing
ID: 9282025
bequette:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 9286100
I'll register an interest!
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 9623207
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Award points to TimCottee

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Anthony
EE Cleanup Volunteer
0

Featured Post

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question