Solved

Query Analyzer: Run sequence of files

Posted on 2003-11-19
3
361 Views
Last Modified: 2006-11-17
Hi All,

I want to create a script that says:

- Run scriptfile 1  (create database script)
- Run scriptfile 2  (create stored procedures script)
- Run scriptfile 3  (fill database script)

What is the syntax for this?
0
Comment
Question by:MelissaC
3 Comments
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 9777374
basically...

osql.exe -dDatabaseName -E -iInputfile -oOutputfile -SserverName


for the create database specify Master or Tempdb as the database

use -E for a trusted connection or -Uuserid -Ppassword for  a sql server login...

invoke osql 3 times once for each script type...

0
 
LVL 2

Author Comment

by:MelissaC
ID: 9777420
OK, so I can create a .bat file to do this. But isn't there a way to say it in a sql-script file?
Some kind of <execute file> statement or something?
0
 
LVL 8

Accepted Solution

by:
dishanf earned 75 total points
ID: 9778829
DECLARE @CMD VARCHAR(800)

SET @CMD = 'osql.exe -dDatabaseName -E -iInputfile -oOutputfile -SserverName'

EXECUTE master..xp_cmdshell @CMD
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

914 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

21 Experts available now in Live!

Get 1:1 Help Now