473,834 Members | 1,794 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 18708
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
7673
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. I've tried everything I could think of but no result at all. Could someone please help me with this or...
5
2343
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 destination database (currently across the network).
16
5094
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 (data)
0
1079
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
1893
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 equivalent, I would have created multiple .dqy files, which would query the database for pages of results as...
3
14022
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 of time scouring google groups but this is all I have found:
0
1345
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 have a scheduled event to fire it off via sFTP from my server.(Although Im opent to ANY Suggestions) ...
1
7580
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
7477
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 add EDI capabilities to an accounting package, but the assumption was made that a full version of...
0
9800
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10802
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10516
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10225
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7763
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5630
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4429
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
2
3987
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3085
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.