<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; DECLARE Multiple Variables in One Statement</title>
	<atom:link href="http://blog.sqlauthority.com/2008/10/31/sql-server-declare-multiple-variables-in-one-statement/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2008/10/31/sql-server-declare-multiple-variables-in-one-statement/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Sun, 12 Feb 2012 09:22:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Arjun Sah</title>
		<link>http://blog.sqlauthority.com/2008/10/31/sql-server-declare-multiple-variables-in-one-statement/#comment-218930</link>
		<dc:creator><![CDATA[Arjun Sah]]></dc:creator>
		<pubDate>Fri, 16 Dec 2011 02:44:23 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1446#comment-218930</guid>
		<description><![CDATA[variable_name datatype [NOT NULL := value ];]]></description>
		<content:encoded><![CDATA[<p>variable_name datatype [NOT NULL := value ];</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/10/31/sql-server-declare-multiple-variables-in-one-statement/#comment-180742</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Wed, 19 Oct 2011 09:44:29 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1446#comment-180742</guid>
		<description><![CDATA[You cannot assign value to variables in where condition. You can only use it for comparison in the where clause]]></description>
		<content:encoded><![CDATA[<p>You cannot assign value to variables in where condition. You can only use it for comparison in the where clause</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ravi</title>
		<link>http://blog.sqlauthority.com/2008/10/31/sql-server-declare-multiple-variables-in-one-statement/#comment-180429</link>
		<dc:creator><![CDATA[ravi]]></dc:creator>
		<pubDate>Tue, 18 Oct 2011 18:50:18 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1446#comment-180429</guid>
		<description><![CDATA[how to assign variable in where condition]]></description>
		<content:encoded><![CDATA[<p>how to assign variable in where condition</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/10/31/sql-server-declare-multiple-variables-in-one-statement/#comment-170593</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Thu, 22 Sep 2011 08:34:44 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1446#comment-170593</guid>
		<description><![CDATA[DECLARE @Var1 INT, @Var2 INT
SET @Var1 = 1
SET @Var2 = 2
if @Var1=@Var2 
print &#039;these are equal&#039;
else
print &#039;these are not equal&#039;]]></description>
		<content:encoded><![CDATA[<p>DECLARE @Var1 INT, @Var2 INT<br />
SET @Var1 = 1<br />
SET @Var2 = 2<br />
if @Var1=@Var2<br />
print &#8216;these are equal&#8217;<br />
else<br />
print &#8216;these are not equal&#8217;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dhaval</title>
		<link>http://blog.sqlauthority.com/2008/10/31/sql-server-declare-multiple-variables-in-one-statement/#comment-170497</link>
		<dc:creator><![CDATA[Dhaval]]></dc:creator>
		<pubDate>Thu, 22 Sep 2011 01:26:55 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1446#comment-170497</guid>
		<description><![CDATA[is there any way to compare these variable,

like 

DECLARE @Var1 INT, @Var2 INT
SET @Var1 = 1
SET @Var2 = 2
SELECT @Var1 &#039;Var1&#039;, @Var2 &#039;Var2&#039;, @Var1 = @Var2 &#039;Compare&#039;]]></description>
		<content:encoded><![CDATA[<p>is there any way to compare these variable,</p>
<p>like </p>
<p>DECLARE @Var1 INT, @Var2 INT<br />
SET @Var1 = 1<br />
SET @Var2 = 2<br />
SELECT @Var1 &#8216;Var1&#8242;, @Var2 &#8216;Var2&#8242;, @Var1 = @Var2 &#8216;Compare&#8217;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mehmet</title>
		<link>http://blog.sqlauthority.com/2008/10/31/sql-server-declare-multiple-variables-in-one-statement/#comment-168463</link>
		<dc:creator><![CDATA[mehmet]]></dc:creator>
		<pubDate>Thu, 15 Sep 2011 19:17:30 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1446#comment-168463</guid>
		<description><![CDATA[HOW TO USE LOCAL VARIABLE INSTEAD OF SELECT STATEMENT IN CURSOR ?

I CAN USE IT IN ORACLE.

LIKE THIS;

SET @STRSQL= &#039;SELECT A FROM TABLE&#039;

OPEN cur FOR @STRSQL]]></description>
		<content:encoded><![CDATA[<p>HOW TO USE LOCAL VARIABLE INSTEAD OF SELECT STATEMENT IN CURSOR ?</p>
<p>I CAN USE IT IN ORACLE.</p>
<p>LIKE THIS;</p>
<p>SET @STRSQL= &#8216;SELECT A FROM TABLE&#8217;</p>
<p>OPEN cur FOR @STRSQL</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rama chandra sahu</title>
		<link>http://blog.sqlauthority.com/2008/10/31/sql-server-declare-multiple-variables-in-one-statement/#comment-167474</link>
		<dc:creator><![CDATA[rama chandra sahu]]></dc:creator>
		<pubDate>Mon, 12 Sep 2011 10:15:09 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1446#comment-167474</guid>
		<description><![CDATA[Is there any performance increase by using single declaration for multiple variables !]]></description>
		<content:encoded><![CDATA[<p>Is there any performance increase by using single declaration for multiple variables !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tarun Dalwani</title>
		<link>http://blog.sqlauthority.com/2008/10/31/sql-server-declare-multiple-variables-in-one-statement/#comment-163949</link>
		<dc:creator><![CDATA[Tarun Dalwani]]></dc:creator>
		<pubDate>Wed, 31 Aug 2011 12:50:14 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1446#comment-163949</guid>
		<description><![CDATA[Hi to all,
I wanted to ask, whether there is any difference between declaring multiple variables in 1 statment and declaring multiple variables in multiple statments (1 in each statement).

I mean, is there any noteworthy difference from the point of view of performance, etc. Is any one better than the other for any reason?]]></description>
		<content:encoded><![CDATA[<p>Hi to all,<br />
I wanted to ask, whether there is any difference between declaring multiple variables in 1 statment and declaring multiple variables in multiple statments (1 in each statement).</p>
<p>I mean, is there any noteworthy difference from the point of view of performance, etc. Is any one better than the other for any reason?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Carl Hager</title>
		<link>http://blog.sqlauthority.com/2008/10/31/sql-server-declare-multiple-variables-in-one-statement/#comment-144723</link>
		<dc:creator><![CDATA[Carl Hager]]></dc:creator>
		<pubDate>Wed, 29 Jun 2011 19:56:57 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1446#comment-144723</guid>
		<description><![CDATA[Greeting Dave and All.

Although an older post, this and many other posts still referenced frequently, so I wanted to add the following exception to the above.

From BOL, when declaring *table variables* specifically, those must be the only variable declared.  A trivial limitation imho, but one to be aware of.

http://msdn.microsoft.com/en-us/library/ms188927.aspx

Carl Hager]]></description>
		<content:encoded><![CDATA[<p>Greeting Dave and All.</p>
<p>Although an older post, this and many other posts still referenced frequently, so I wanted to add the following exception to the above.</p>
<p>From BOL, when declaring *table variables* specifically, those must be the only variable declared.  A trivial limitation imho, but one to be aware of.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms188927.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms188927.aspx</a></p>
<p>Carl Hager</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/10/31/sql-server-declare-multiple-variables-in-one-statement/#comment-116022</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Fri, 04 Feb 2011 11:25:45 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1446#comment-116022</guid>
		<description><![CDATA[What do you want to do with a cursor?]]></description>
		<content:encoded><![CDATA[<p>What do you want to do with a cursor?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hemant</title>
		<link>http://blog.sqlauthority.com/2008/10/31/sql-server-declare-multiple-variables-in-one-statement/#comment-115666</link>
		<dc:creator><![CDATA[hemant]]></dc:creator>
		<pubDate>Wed, 02 Feb 2011 12:30:35 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1446#comment-115666</guid>
		<description><![CDATA[Hi
i want to use cursor but in sql server 2005 there is no %table-type%,we have to create individual field and set into
fetch statement and even we can not get field like cursorName.FieldName in sql server like orale.


Send Me Reply if you have any alternate to cursor.



Thanking You

Hemant Patel]]></description>
		<content:encoded><![CDATA[<p>Hi<br />
i want to use cursor but in sql server 2005 there is no %table-type%,we have to create individual field and set into<br />
fetch statement and even we can not get field like cursorName.FieldName in sql server like orale.</p>
<p>Send Me Reply if you have any alternate to cursor.</p>
<p>Thanking You</p>
<p>Hemant Patel</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: desigan</title>
		<link>http://blog.sqlauthority.com/2008/10/31/sql-server-declare-multiple-variables-in-one-statement/#comment-103572</link>
		<dc:creator><![CDATA[desigan]]></dc:creator>
		<pubDate>Fri, 03 Dec 2010 10:53:56 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1446#comment-103572</guid>
		<description><![CDATA[Hi all,
       Im using cursor in my procedure,Im getting the value from 1 table,that value is stored in local variable @var,that value is the column name of another table.I want to pass the @var in Cursor Select Statement.How i do that..the Below statements im using...

Set @var=(select field from table1)

Declare cursorname cursor for
Select @var from table2 where No=2   ---&gt;Getting Error
open cursorname]]></description>
		<content:encoded><![CDATA[<p>Hi all,<br />
       Im using cursor in my procedure,Im getting the value from 1 table,that value is stored in local variable @var,that value is the column name of another table.I want to pass the @var in Cursor Select Statement.How i do that..the Below statements im using&#8230;</p>
<p>Set @var=(select field from table1)</p>
<p>Declare cursorname cursor for<br />
Select @var from table2 where No=2   &#8212;&gt;Getting Error<br />
open cursorname</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Binay TIwari</title>
		<link>http://blog.sqlauthority.com/2008/10/31/sql-server-declare-multiple-variables-in-one-statement/#comment-87319</link>
		<dc:creator><![CDATA[Binay TIwari]]></dc:creator>
		<pubDate>Fri, 10 Sep 2010 05:28:43 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1446#comment-87319</guid>
		<description><![CDATA[Can we declare and initialize variables in one line]]></description>
		<content:encoded><![CDATA[<p>Can we declare and initialize variables in one line</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Binay TIwari</title>
		<link>http://blog.sqlauthority.com/2008/10/31/sql-server-declare-multiple-variables-in-one-statement/#comment-81843</link>
		<dc:creator><![CDATA[Binay TIwari]]></dc:creator>
		<pubDate>Tue, 27 Jul 2010 12:21:29 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1446#comment-81843</guid>
		<description><![CDATA[Thanks for the tutorial.Is it possible to deallocate local variable?]]></description>
		<content:encoded><![CDATA[<p>Thanks for the tutorial.Is it possible to deallocate local variable?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Himadri</title>
		<link>http://blog.sqlauthority.com/2008/10/31/sql-server-declare-multiple-variables-in-one-statement/#comment-62919</link>
		<dc:creator><![CDATA[Himadri]]></dc:creator>
		<pubDate>Mon, 15 Mar 2010 05:32:52 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1446#comment-62919</guid>
		<description><![CDATA[Thanks for providing such useful information.

Himadri]]></description>
		<content:encoded><![CDATA[<p>Thanks for providing such useful information.</p>
<p>Himadri</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/10/31/sql-server-declare-multiple-variables-in-one-statement/#comment-61958</link>
		<dc:creator><![CDATA[Madhivanan]]></dc:creator>
		<pubDate>Mon, 01 Mar 2010 08:28:11 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1446#comment-61958</guid>
		<description><![CDATA[Probably you may need

select Name=lastname firstname from emp
UNION ALL
SELECT firstname from emp]]></description>
		<content:encoded><![CDATA[<p>Probably you may need</p>
<p>select Name=lastname firstname from emp<br />
UNION ALL<br />
SELECT firstname from emp</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/10/31/sql-server-declare-multiple-variables-in-one-statement/#comment-61957</link>
		<dc:creator><![CDATA[Madhivanan]]></dc:creator>
		<pubDate>Mon, 01 Mar 2010 08:27:09 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1446#comment-61957</guid>
		<description><![CDATA[There is no need and no way to do it

Use GO as a batch seperator so that variables would lose the scope]]></description>
		<content:encoded><![CDATA[<p>There is no need and no way to do it</p>
<p>Use GO as a batch seperator so that variables would lose the scope</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rajesh</title>
		<link>http://blog.sqlauthority.com/2008/10/31/sql-server-declare-multiple-variables-in-one-statement/#comment-57047</link>
		<dc:creator><![CDATA[Rajesh]]></dc:creator>
		<pubDate>Mon, 26 Oct 2009 19:53:51 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1446#comment-57047</guid>
		<description><![CDATA[I want display like under from 

select Name=lastname+&#039; &#039;+firstname from emp

but all firstname should be left align like under one column.

Thanks
Rajesh]]></description>
		<content:encoded><![CDATA[<p>I want display like under from </p>
<p>select Name=lastname+&#8217; &#8216;+firstname from emp</p>
<p>but all firstname should be left align like under one column.</p>
<p>Thanks<br />
Rajesh</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: J</title>
		<link>http://blog.sqlauthority.com/2008/10/31/sql-server-declare-multiple-variables-in-one-statement/#comment-51049</link>
		<dc:creator><![CDATA[J]]></dc:creator>
		<pubDate>Thu, 16 Apr 2009 18:59:27 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1446#comment-51049</guid>
		<description><![CDATA[Can we undeclare variables?  We can deallocate CURSOR varilable, how can we deallocate or undeclare local variable?

Thanks
J]]></description>
		<content:encoded><![CDATA[<p>Can we undeclare variables?  We can deallocate CURSOR varilable, how can we deallocate or undeclare local variable?</p>
<p>Thanks<br />
J</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: R.Alamsha</title>
		<link>http://blog.sqlauthority.com/2008/10/31/sql-server-declare-multiple-variables-in-one-statement/#comment-45728</link>
		<dc:creator><![CDATA[R.Alamsha]]></dc:creator>
		<pubDate>Mon, 19 Jan 2009 10:39:33 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1446#comment-45728</guid>
		<description><![CDATA[Thanks for the tutorial.

I have a table like this:

TagKey TagID TagvALUE TagTimeStamp

I want to create this constraint:

&quot;If the previous TagValue = current TagValue then do not update&quot;.

Can you help me, please?. Thanks.]]></description>
		<content:encoded><![CDATA[<p>Thanks for the tutorial.</p>
<p>I have a table like this:</p>
<p>TagKey TagID TagvALUE TagTimeStamp</p>
<p>I want to create this constraint:</p>
<p>&#8220;If the previous TagValue = current TagValue then do not update&#8221;.</p>
<p>Can you help me, please?. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://blog.sqlauthority.com/2008/10/31/sql-server-declare-multiple-variables-in-one-statement/#comment-44021</link>
		<dc:creator><![CDATA[John]]></dc:creator>
		<pubDate>Sun, 02 Nov 2008 19:35:33 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1446#comment-44021</guid>
		<description><![CDATA[Same goes for assigning variables from a query

Select @Var1 = Col1, @Var2 = Col2 From Table ...]]></description>
		<content:encoded><![CDATA[<p>Same goes for assigning variables from a query</p>
<p>Select @Var1 = Col1, @Var2 = Col2 From Table &#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://blog.sqlauthority.com/2008/10/31/sql-server-declare-multiple-variables-in-one-statement/#comment-44016</link>
		<dc:creator><![CDATA[Eric]]></dc:creator>
		<pubDate>Sun, 02 Nov 2008 14:52:30 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1446#comment-44016</guid>
		<description><![CDATA[Method 3: Single statements for declaring and defining multiple variables:

DECLARE @Var1 INT, @Var2 INT
SELECT @Var1 = 1, @Var2 = 2
SELECT @Var1 &#039;Var1&#039;, @Var2 &#039;Var2&#039;
GO]]></description>
		<content:encoded><![CDATA[<p>Method 3: Single statements for declaring and defining multiple variables:</p>
<p>DECLARE @Var1 INT, @Var2 INT<br />
SELECT @Var1 = 1, @Var2 = 2<br />
SELECT @Var1 &#8216;Var1&#8242;, @Var2 &#8216;Var2&#8242;<br />
GO</p>
]]></content:encoded>
	</item>
</channel>
</rss>

