﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / T-SQL (SS2K8)  / Change a variable based on the results / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Wed, 19 Jun 2013 01:28:30 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Change a variable based on the results</title><link>http://www.sqlservercentral.com/Forums/Topic1035716-392-1.aspx</link><description>Excellent. Thanks for your help.</description><pubDate>Thu, 16 Dec 2010 04:11:35 GMT</pubDate><dc:creator>zuma01</dc:creator></item><item><title>RE: Change a variable based on the results</title><link>http://www.sqlservercentral.com/Forums/Topic1035716-392-1.aspx</link><description>DECLARE @NextMonth AS nvarchar(7)SET @NextMonth = LEFT(datename(mm, dateadd(month, 1, GETDATE())), 3) + '-' + RIGHT(datename(yy, getdate()), 2)if @nextmonth = 'Jan-10' set @NextMonth = LEFT(datename(mm, dateadd(month, 1, GETDATE())), 3) + '-' + RIGHT(datename(yy, getdate())+1, 2)else set @NextMonth =  LEFT(datename(mm, dateadd(month, 1, GETDATE())), 3) + '-' + RIGHT(datename(yy, getdate()), 2)select @nextmonth</description><pubDate>Thu, 16 Dec 2010 03:39:40 GMT</pubDate><dc:creator>Sachin Nandanwar</dc:creator></item><item><title>Change a variable based on the results</title><link>http://www.sqlservercentral.com/Forums/Topic1035716-392-1.aspx</link><description>Hi,I am trying to change a variable based on the results of the same variable. Is this possible or do I need to go about this some other way.Code below: DECLARE @NextMonth AS nvarchar(7)SET                @NextMonth = LEFT(datename(mm, dateadd(month, 1, GETDATE())), 3) + '-' + RIGHT(datename(yy, getdate()), 2)if @nextmonth = 'Jan-10' then   @NextMonth = LEFT(datename(mm, dateadd(month, 1, GETDATE())), 3) + '-' + RIGHT(datename(yy, getdate()),+1, 2)else s @NextMonth = LEFT(datename(mm, dateadd(month, 1, GETDATE())), 3) + '-' + RIGHT(datename(yy, getdate()), 2)select @nextmonth</description><pubDate>Thu, 16 Dec 2010 03:16:21 GMT</pubDate><dc:creator>zuma01</dc:creator></item></channel></rss>