devxlogo

Run a SQL Script File Using T-SQL

Run a SQL Script File Using T-SQL

There’s no direct command to read a script file and execute it. But isql.exe and osql.exe come in handy when you have to execute a script file from within T-SQL. Just call any of these exes using xp_cmdshell and pass the script file name as parameter to it:

 EXEC master..xp_cmdshell 'osql -Svaio -Usa -Pzaassds1 -ic:MySQl.sql -n'EXEC master..xp_cmdshell 'isql -Svaio -Usa -Pzaassds1 -ic:MySQl.sql -n'

devx-admin

Share the Post: