Executes the SQL statements in the supplied file.
The path of a text file containing SQL statements. The path becomes the current working directory for any further files to be included. If the path is not absolute, and if the @@SCRIPTURI is set, then the result is the combination of 'filename' as relative to @@SCRIPTURI.
Nesting of include files is supported. Variables are visible to a nested include file.
Recursion is possible, but limited to 100 files.
1) Conditional include
IF version = '1.0'
2) Variable is used across included files
DECLARE @log bit = 0
INCLUDE 'C:\Documents and Settings\All Users\Documents\stage1.sql'
IF @log = 1 THEN PRINT 'starting stage1...'
IF @log = 1 THEN PRINT stage1 complete'
IF @log = 1 THEN PRINT 'starting stage2...'
IF @log = 1 THEN PRINT stage2 complete'