i want to call a series of .sql scripts to create the initial database structure
is there any way of doing this without sqlcmd or stored procedures or any other kind of code that is not sql ? just inside a .sql file.
If your scripts are . sql (or any kind of text) file, as @Abe Miesller says (upvoted) you can run them from within SSMS via the :r command, when SQLCMD mode is enabled. You would have to know and script the exact file path and name. This cannot be done from within a stored procedure.
you could try this:
exec master..xp_cmdshell 'osql -E -ix:\path\filename.sql'
osql must be in the path, the full filename must be known, and logins have to be set up correctly (options -E or -U)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With