Solved

Running SQL Scripts

Posted on 2001-07-18
7
982 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
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now