Solved

Query Analyzer: Run sequence of files

Posted on 2003-11-19
3
363 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

Suggested Solutions

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

773 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