SQL CMD

Home / SQL CMD

SQL CMD tokens are replaced with their literal values prior TSQL parsing, so they can be used in places where a @ variable wouldn’t be permitted. Typically used for running queries within the SQL Server Management Studio, but such queries can be processed externally by calling SQLCMD.EXE (C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\SQLCMD.EXE). The literals are not scoped by GO statements like an @ variable and they can be re-defined later in the TSQL

Enable SQL CMD processing from the SQL Server Management Studio

EnableSQLCmdMode

Example SQL

Example C# – Using SQLCMD.EXE to run scripts