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.