p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

sql_server_dts thread: Runnin sql script in sql server


Message #1 by "Raj Mehta" <rajwrox@h...> on Thu, 13 Mar 2003 12:26:17 -0800
Actually the below is more clear:

del SP.log
del job.log

for %%f in (StoredProcedures\*.sql) do osql -dWinDataExchange -n -Usa -P -i
%%f >> SP.log
for %%f in (Jobs\*.sql) do osql -dWinDataExchange -n -Usa -P -i %%f >>
Job.log

type SP.log
type Job.log


___________________________
Joe Horton
Database Developer / Software Engineer
WISHA/Legal Services Software Development
Department of Labor and Industries
Voice  (xxx) xxx-xxxx   fax  (xxx) xxx-xxxx

 -----Original Message-----
From: 	Horton, Joe (LNI)  
Sent:	Thursday, March 13, 2003 1:28 PM
To:	'SQL Server DTS'
Subject:	RE: [sql_server_dts] RE: Runnin sql script in sql server

Here is code we use for this exact same thing.  We track the results to
UpdateSQL.log and loop through files in StoredProcedures folder.  This works
great when you are doing a rather large DB drop and have many OJBECTS to
load


del UpdateSQL.log
del SP.log
del job.log

osql -dWinDataExchange -n -Usa -P -i Update_1.4_to_2.0.sql -o UpdateSQL.log 

for %%f in (StoredProcedures\*.sql) do osql -dWinDataExchange -n -Usa -P -i
%%f >> SP.log
for %%f in (Jobs\*.sql) do osql -dWinDataExchange -n -Usa -P -i %%f >>
Job.log

type UpdateSQL.log
type SP.log
type Job.log



___________________________
Joe Horton
Database Developer / Software Engineer
WISHA/Legal Services Software Development
Department of Labor and Industries
Voice  (xxx) xxx-xxxx   fax  (xxx) xxx-xxxx

 -----Original Message-----
From: 	Brian Freeman [mailto:freeman@C...] 
Sent:	Thursday, March 13, 2003 12:42 PM
To:	SQL Server DTS
Subject:	[sql_server_dts] RE: Runnin sql script in sql server

What front end are you running.  
From DTS you can put the .sql file text into an execute query task.
From command line (or batch file) you can run osql utility.
Interactive you can load .sql files in query analyzer and run.
From program with ADO (such as VB/ ASP.Net etc) you can read the text from
the file and execute the commands (i.e. strsql=-data loaded from file
con.execute(strsql))

If you need to run it another way or different front end please post further
information.

Brian Freeman
(xxx) xxx-xxxx  ext. 415
Carnegie Technologies/Bluewave Computing 
www.carnegie.com and www.bluewave-computing.com

-----Original Message-----
From: Raj Mehta [mailto:rajwrox@h...]
Sent: Thursday, March 13, 2003 3:26 PM
To: SQL Server DTS
Subject: [sql_server_dts] Runnin sql script in sql server


Hi all:

This is very simple questions but I would still appreciate any help on this.

The question is how do I run a .sql script in SQL server. e.g I am creating 
10 tables and I don't want to run DDL for each table but just want to make 
one .sql file and run to create tables.

Thanks,
Rajesh Mehta

_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE*  
http://join.msn.com/?page=features/virus





  Return to Index