Solved

Running SQL Scripts

Posted on 2001-07-18
7
985 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

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

Backup Solution for AWS

Read about how CloudBerry Backup fully integrates your backups with Amazon S3 and Amazon Glacier to provide military-grade encryption and dramatically cut storage costs on any platform.

Question has a verified solution.

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

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

763 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