Sql-server – How to call a SQL script from within another SQL script


i want to call a series of .sql scripts to create the initial database structure

  1. script1.sql
  2. script2.sql

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.

Best Solution

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)