<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SQLCMD &#8211; SQLpowered.com</title>
	<atom:link href="https://sqlpowered.com/command-category/sqlcmd/feed/" rel="self" type="application/rss+xml" />
	<link>https://sqlpowered.com</link>
	<description>SQL Server + BI</description>
	<lastBuildDate>Sun, 08 Jan 2023 13:08:03 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://sqlpowered.com/wp-content/uploads/2020/07/FavIcon-e1594067873682-99x100.png</url>
	<title>SQLCMD &#8211; SQLpowered.com</title>
	<link>https://sqlpowered.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>SQLCMD &#8211; Basic commands</title>
		<link>https://sqlpowered.com/t-sql-commands/5269-2/</link>
		
		<dc:creator><![CDATA[Jan Dvořák]]></dc:creator>
		<pubDate>Mon, 27 Dec 2021 09:55:00 +0000</pubDate>
				<category><![CDATA[T-SQLpowered]]></category>
		<guid isPermaLink="false">https://sqlpowered.com/?post_type=t-sql-commands&#038;p=5269</guid>

					<description><![CDATA[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...]]></description>
										<content:encoded><![CDATA[<p>Check if SQLCMD mode is enabled in SSMS:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="sql">: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</pre>
<p>Declare database name as variable and switch database context:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="sql">:SETVAR Database "MyDatabase"

USE [$(Database)]
GO</pre>
<p>Execute/Include commands from SQL file:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="sql">:r "C:\SQLFiles\File1.sql"
GO</pre>
<p>&nbsp;</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
