?
Solved

Query Analyzer: Run sequence of files

Posted on 2003-11-19
3
Medium Priority
?
371 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
[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
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:
Dishan Fernando earned 300 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
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 SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Suggested Courses

762 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