Solved

Query Analyzer: Run sequence of files

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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
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…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.

688 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