469,133 Members | 1,153 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,133 developers. It's quick & easy.

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 18250
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
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.