473,569 Members | 2,834 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TSQL command to call *.sql files

I have several *.sql files with schema/data changes to be applied to our
current database. Is there a way to create a TSQL script that could be run
from the SQL Query Analyzer that would sequentially call the *.sql files?
i.e.

call schemaVersionCh eck.sql
call addFieldToLoanT able.sql
call updateLoanTrigg er.sql
call updateSchemaVer sion
tia.

dynoweb
Jul 20 '05 #1
2 18694
dynoweb <dy*****@nospam .com> wrote in message news:<Xn******* **************@ 216.196.97.138> ...
I have several *.sql files with schema/data changes to be applied to our
current database. Is there a way to create a TSQL script that could be run
from the SQL Query Analyzer that would sequentially call the *.sql files?
i.e.

call schemaVersionCh eck.sql
call addFieldToLoanT able.sql
call updateLoanTrigg er.sql
call updateSchemaVer sion
tia.

dynoweb


No, there is no easy way to do this from TSQL - the usual approach is
to use osql.exe from the command line, perhaps called from a batch
file or script.

Simon
Jul 20 '05 #2
sq*@hayes.ch (Simon Hayes) wrote in message news:<60******* *************** ****@posting.go ogle.com>...
dynoweb <dy*****@nospam .com> wrote in message news:<Xn******* **************@ 216.196.97.138> ...
I have several *.sql files with schema/data changes to be applied to our
current database. Is there a way to create a TSQL script that could be run
from the SQL Query Analyzer that would sequentially call the *.sql files?
i.e.

call schemaVersionCh eck.sql
call addFieldToLoanT able.sql
call updateLoanTrigg er.sql
call updateSchemaVer sion
tia.

dynoweb


No, there is no easy way to do this from TSQL - the usual approach is
to use osql.exe from the command line, perhaps called from a batch
file or script.

Simon


Well, there kinda is. In your TSQL you could always do:

exec master..xp_cmds hell 'osql -E -ix:\path\filena me.sql'

Alternately you could write a batch file that calls osql sequentially
with all of your *.sql files then use the xp_cmdshell proc to invoke
the batch file.

Wouldn't recommend it with standard security though unless you want
credentials in your TSQL or your batch file when you invoke osql.
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
7655
by: René | last post by:
Hello group, I have a question about a script i use. The function of the script is to dynamically write an ftp script and execute this with dos ftp.exe . This script always worked on a Windows 2000 pro workstation. Now i have moved it to a Windows XP pro workstation it writes the ftp command file but the command doesn't execute anymore....
5
2334
by: murray_shane56 | last post by:
I have a custom application that on occasion requires thousands of TSQL files (on the file system) to be compiled to the database. What is the quickest way to accomplish this? We currently have a small vbs script that gets a list of all the files, the loops around a call to "osql". each call to osql opens/closes a connection to the...
16
5066
by: David Lozzi | last post by:
Hello, I have some code that adds a new user. The new user has a checkboxlist of items which they can be associated with. I would like to send this list of items to TSQL along with the new user information. I would guess to combine the selected items like so: "6,4,8,19,2". Kind of do the following: INSERT into tblUser (fields) VALUES...
0
1065
by: Daniel | last post by:
will a client application using ado.net get an exception if the command is executing a stored procedure that does a RAISEERROR in its tsql?
4
1881
by: roman.ali | last post by:
Hi, I am using a .dqy file to import some rows from a sql server 2003 database to microsoft excel. Unfortunately, I have am importing more rows than excel can handle. Is there a way around this? It appears that there is no equivalent of the LIMIT(offset, number of rows to return) function of mysql in tsql. Had there been an...
3
14001
by: SQLJunkie | last post by:
Happy New Year everyone! I would like to capture CPU Utilization % using TSQL. I know this can be done using PerfMon but I would like to run TSQL command (maybe once every 5 minutes) and see what is the CPU Utilization at that instant so that I can insert the value in a table and run reports based on the data. I have spent a good amount...
0
1335
by: dharper | last post by:
Hi! I'm new to sql 2005 and need to run an automated report that is a fairly simple fixed width ragged right report. Problem is I need a header in the report that has static text, plus the rowcount of the report. I am using an SSIS package to call the script. I think that's the way to go because I need it to run on Friday's at 3:00. Then I'll...
1
7548
by: michael | last post by:
Hi I was wondering if anyone new how to access the call stack information via TSQL I'm currently in the process of migrating an application from Oracle to Sql Server 2005 There is a long running batch process where we currently catch the error and collect the information of the call stack and allow the
2
7464
by: Carlton Kirby | last post by:
I need to execute a job on a SQL Express 2005 instance (no SQLAgent). The job will be executed manually by a user, so it doesn't need to be scheduled to run automatically. I thought I could execute the job through a stored procedure, but it appears that SQL Agent is necessary even for that. The job was given to me by a software vendor to...
0
7605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7917
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7665
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6277
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5501
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2105
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.