473,378 Members | 1,449 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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 schemaVersionCheck.sql
call addFieldToLoanTable.sql
call updateLoanTrigger.sql
call updateSchemaVersion
tia.

dynoweb
Jul 20 '05 #1
2 18684
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 schemaVersionCheck.sql
call addFieldToLoanTable.sql
call updateLoanTrigger.sql
call updateSchemaVersion
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.google. 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 schemaVersionCheck.sql
call addFieldToLoanTable.sql
call updateLoanTrigger.sql
call updateSchemaVersion
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_cmdshell 'osql -E -ix:\path\filename.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
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...
5
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...
16
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...
0
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
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...
3
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...
0
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...
1
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...
2
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.