I am writing SQL Server deployment scripts which create SQL Server job automatically on a specific SQL Server server/instance. I have found that I can extract the sql statem
Futher to BrianD's answer above, you can define variables (actually more like preprocessor macros than variables) at the sqlcmd level; these are enclosed in parentheses with a leading $ sign:
SET @JobName = '$(JobName)'
SET @Owner = '$(Owner)'
This allows you to pass the information on the command line to sqlcmd with the -v switch:
sqlcmd -... -i create_jobs.sql -v JobName=Job1 -v Owner=BrianD