T-SQLpowered

SQLCMD - Basic commands

Check if SQLCMD mode is enabled in SSMS: :setvar __IsSqlCmdEnabled “True” GO IF N’$(__IsSqlCmdEnabled)’ NOT LIKE N’True’ BEGIN PRINT N’SQLCMD mode must be enabled to successfully execute this script.’; SET NOEXEC ON; END GO Declare database name as variable and switch database context: :SETVAR Database “MyDatabase” USE [$(Database)] GO Execute/Include…

Read more