To connect to an instance, instance1, of SQL Server, myserver, by using integrated security, you would include the following command:
:connect myserver\instance1.
To connect to the default instance of myserver using scripting variables, you would include the following command:
:setvar myusername test
:setvar myservername myserver
:connect $(myservername) $(myusername)
To execute a simple query stored in the selectFromTable.sql file in C:\Files, you would include the following command:
:SETVAR tablevar Suppliers
:r C:\Files\selectFromTable.sql
GO
:SETVAR tablevar Customers
:r C:\Files\selectFromTable.sql
GO
The selectFromTable.sql file contains the following example query:
SELECT * FROM $(tablevar)
GO