471,853 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,853 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 18500
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by René | last post: by
16 posts views Thread by David Lozzi | last post: by
3 posts views Thread by SQLJunkie | last post: by
1 post views Thread by michael | last post: by
NeoPa
reply views Thread by NeoPa | last post: by
reply views Thread by YellowAndGreen | last post: by
aboka
reply views Thread by aboka | last post: by

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.