 




<?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>IT Answers &#187; T-SQL</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/tag/t-sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers</link>
	<description></description>
	<lastBuildDate>Sat, 18 May 2013 21:33:01 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>SQL or T-SQL</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/sql-or-t-sql/</link>
		<comments>http://itknowledgeexchange.techtarget.com/itanswers/sql-or-t-sql/#comments</comments>
		<pubDate>Wed, 07 Nov 2012 22:13:47 +0000</pubDate>
		<dc:creator>BJ2012</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/sql-or-t-sql/</guid>
		<description><![CDATA[New Discussion Post by Colin Smith]]></description>
				<content:encoded><![CDATA[New Discussion Post by Colin Smith]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/itanswers/sql-or-t-sql/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How do I subtract 3 days from current date only when current day = 2, so that I retrieve the previous Fridays date?</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/how-do-i-subtract-3-days-from-current-date-only-when-current-day-2-or-monday-so-that-i-retriieve-the-previous-fridays-date/</link>
		<comments>http://itknowledgeexchange.techtarget.com/itanswers/how-do-i-subtract-3-days-from-current-date-only-when-current-day-2-or-monday-so-that-i-retriieve-the-previous-fridays-date/#comments</comments>
		<pubDate>Mon, 09 Apr 2012 19:59:41 +0000</pubDate>
		<dc:creator>Kathyb624</dc:creator>
				<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[T-SQL 2008 R2]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[I am new to using T-SQL, so there is probably an easy way to accomplish this, but I can&#8217;t seem to get it right.  I want to retrieve the previous day&#8217;s date (requires a weekday) to use as a comparsioin to a date field in the table, format is YYYYMMDD.  When the current date is [...]]]></description>
				<content:encoded><![CDATA[<p>I am new to using T-SQL, so there is probably an easy way to accomplish this, but I can&#8217;t seem to get it right.  I want to retrieve the previous day&#8217;s date (requires a weekday) to use as a comparsioin to a date field in the table, format is YYYYMMDD.  When the current date is a Monday, I need to subtract 3 days from current date, otherwise subtract 1 day.</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/itanswers/how-do-i-subtract-3-days-from-current-date-only-when-current-day-2-or-monday-so-that-i-retriieve-the-previous-fridays-date/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>t-sql and AS400</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/t-sql-and-as400/</link>
		<comments>http://itknowledgeexchange.techtarget.com/itanswers/t-sql-and-as400/#comments</comments>
		<pubDate>Mon, 19 Sep 2011 12:34:17 +0000</pubDate>
		<dc:creator>CompEng</dc:creator>
				<category><![CDATA[AS/400 Query]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[New Answer by]]></description>
				<content:encoded><![CDATA[New Answer by ]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/itanswers/t-sql-and-as400/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Ageing Report T-SQL</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/ageing-report-t-sql/</link>
		<comments>http://itknowledgeexchange.techtarget.com/itanswers/ageing-report-t-sql/#comments</comments>
		<pubDate>Wed, 07 Sep 2011 13:29:18 +0000</pubDate>
		<dc:creator>Sanisto</dc:creator>
				<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[SAP Aging Reports]]></category>
		<category><![CDATA[SQL 2005]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Im trying to write a query to retrive debtors ageing report in sql I have two tables [strong]1. Billing(billAmount,BillDate,AccountNo)[/strong] [strong]2.Payments(payAmount,payDate,AccountNo)[/strong] I need the output to show ageigng [strong]0-30, 31-60, 61-90, 91+[/strong] with the balances for each period The Billing table is pre-populated with the charges per month as per the amortization schedule when a client [...]]]></description>
				<content:encoded><![CDATA[<p>Im trying to write a query to retrive debtors ageing report in sql I have two tables [strong]1. Billing(billAmount,BillDate,AccountNo)[/strong] [strong]2.Payments(payAmount,payDate,AccountNo)[/strong] I need the output to show ageigng [strong]0-30, 31-60, 61-90, 91+[/strong] with the balances for each period The Billing table is pre-populated with the charges per month as per the amortization schedule when a client signs a contract to buy a car and the Payments table records payments made every month by clients</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/itanswers/ageing-report-t-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server 2008 Insert Into vs Insert Statement Recompile</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/sql-server-2008-insert-into-vs-insert-statement-recompile/</link>
		<comments>http://itknowledgeexchange.techtarget.com/itanswers/sql-server-2008-insert-into-vs-insert-statement-recompile/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 19:34:09 +0000</pubDate>
		<dc:creator>Rick Martinez</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[I have a stored procedure that executes a t-sql statement using sp_executesql. This t-sql code recompiles everytime it runs using &#8220;INSERT INTO&#8221; but when I use &#8220;INSERT&#8221; only it will not recompile. What is going on here? sample: create table #test (id int) Recompile: insert into #test select id from mytable Not Recompile: insert #test [...]]]></description>
				<content:encoded><![CDATA[<p>I have a stored procedure that executes a t-sql statement using sp_executesql. This t-sql code recompiles everytime it runs using &#8220;INSERT INTO&#8221; but when I use &#8220;INSERT&#8221; only it will not recompile. What is going on here?<br/><br/> sample:<br/><br/> create table #test (id int)<br/><br/> Recompile:<br/><br/> insert into #test select id from mytable<br/><br/> Not Recompile:<br/><br/> insert #test select id from mytable<br/><br/></p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/itanswers/sql-server-2008-insert-into-vs-insert-statement-recompile/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to concat SQL Server 2005 data with line feed</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/how-to-concat-data-with-line-feed/</link>
		<comments>http://itknowledgeexchange.techtarget.com/itanswers/how-to-concat-data-with-line-feed/#comments</comments>
		<pubDate>Tue, 01 Feb 2011 22:46:35 +0000</pubDate>
		<dc:creator>TLMercer</dc:creator>
				<category><![CDATA[Access 2003]]></category>
		<category><![CDATA[Concatenate]]></category>
		<category><![CDATA[Line Feed]]></category>
		<category><![CDATA[SQL 2005]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[I am attempting to update a column in SQL Server 2005 by concatenating data from two other columns and include a line feed between the two and have the second line begin with a /. The data will be viewed through an MS Access 2003 database with a linked table using an ODBC connection. The [...]]]></description>
				<content:encoded><![CDATA[<p>I am attempting to update a column in SQL Server 2005 by concatenating data from two other columns and include a line feed between the two and have the second line begin with a /. <br/><br/> The data will be viewed through an MS Access 2003 database with a linked table using an ODBC connection. The script I am using in MS SQL Server Management Studio Query window is: <br/><br/> update tblinventory set abstract = [title_1]+char(10)+char(13)+&#8217;/'+[Title_2] where ITEM_NO = 10850 <br/><br/> However, when the results are viewed using Access I see in the abstract column data from title_one “two boxes” a / and data from title_two. <br/><br/> I would expect to see the /and data from title_two on a different line.<br/><br/>  An example is data in title_1 = Houston data in title_2 = Texas; I would expect to see data returned in abstract as Houston new line /Texas However when viewed through the linked table in Access I see in column abstract Houston BOX BOX  [two][/two]/Texas all on the same line the two boxes I assume are the special characters for line feed and carrige return but Access is not interpreting them correctly. When the same row of data is viewed through MS SQL Server Management Studio Query window the data for abstract is displayed on one line as: Houston  /Texas. <br/><br/> Can anyone assist with this issue? Thanks in advance<br/><br/></p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/itanswers/how-to-concat-data-with-line-feed/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>iSeries SQL ISNULL Equivalent</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/iseries-sql-isnull-equivalent/</link>
		<comments>http://itknowledgeexchange.techtarget.com/itanswers/iseries-sql-isnull-equivalent/#comments</comments>
		<pubDate>Wed, 26 Jan 2011 22:28:26 +0000</pubDate>
		<dc:creator>Jaggerdude</dc:creator>
				<category><![CDATA[AS/400]]></category>
		<category><![CDATA[iSeries Access]]></category>
		<category><![CDATA[iSeries Navigator]]></category>
		<category><![CDATA[iSeries SQL]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[What is the equivalent of the function ISNULL in t-sql in AS/400 iSeries Navigator SQL? or the equivalent of the NZ function in Access?]]></description>
				<content:encoded><![CDATA[<p>What is the equivalent of the function ISNULL in t-sql in AS/400 iSeries Navigator SQL? or the equivalent of the NZ function in Access?</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/itanswers/iseries-sql-isnull-equivalent/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>T-SQL Programming Tutorials</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/t-sql-programming-tutorials/</link>
		<comments>http://itknowledgeexchange.techtarget.com/itanswers/t-sql-programming-tutorials/#comments</comments>
		<pubDate>Fri, 03 Dec 2010 17:18:46 +0000</pubDate>
		<dc:creator>Luby</dc:creator>
				<category><![CDATA[SQL 2005 Database]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[I am looking for a website that is free and where I can learn to write better T-SQL views and stored procedures.  Also, would like to find some good books to learn more about managing a SQL 2005 database.]]></description>
				<content:encoded><![CDATA[<p>I am looking for a website that is free and where I can learn to write better T-SQL views and stored procedures.  Also, would like to find some good books to learn more about managing a SQL 2005 database.</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/itanswers/t-sql-programming-tutorials/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>T-SQL with Recursion &#8211; Display top ID on all levels below (To: Kent Milligan)</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/t-sql-with-recursion-display-top-id-on-all-levels-below-to-kent-milligan/</link>
		<comments>http://itknowledgeexchange.techtarget.com/itanswers/t-sql-with-recursion-display-top-id-on-all-levels-below-to-kent-milligan/#comments</comments>
		<pubDate>Wed, 24 Nov 2010 13:36:41 +0000</pubDate>
		<dc:creator>Cavallino</dc:creator>
				<category><![CDATA[Recursion]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[V5R4]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Hell Kent, I read through &#8220;V5R4 SQL Packs a Punch&#8221; http://www-03.ibm.com/systems/resources/systems_i_software_db2_pdf_rcte_olap.pdf    I would need the query in figure 20 and the result in figure 21 which do not show up in the article.  I have a query similar to the example (parts of an iSeries Power5 server) that shows all the levels correctly, however, [...]]]></description>
				<content:encoded><![CDATA[<p>Hell Kent,<br/><br/> I read through &#8220;V5R4 SQL Packs a Punch&#8221; <a target="_blank" href="http://www-03.ibm.com/systems/resources/systems_i_software_db2_pdf_rcte_olap.pdf" title="here">http://www-03.ibm.com/systems/resources/systems_i_software_db2_pdf_rcte_olap.pdf</a>   <br/><br/> I would need the query in figure 20 and the result in figure 21 which do not show up in the article. <br/><br/> I have a query similar to the example (parts of an iSeries Power5 server) that shows all the levels correctly, however, I must display the top level part of the recursion in every line of the result. (In the example there should be a field &#8220;Product&#8221; filled with &#8220;iSeries Power5 server&#8221; in every line of the result.). I must be able to distinguish the parts of different products.<br/><br/> Would you be so kind and post the corresponding T-SQL query?<br/><br/> regards arno<br/><br/>  <br/><br/></p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/itanswers/t-sql-with-recursion-display-top-id-on-all-levels-below-to-kent-milligan/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Parameter in select statement</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/parameter-in-select-statement/</link>
		<comments>http://itknowledgeexchange.techtarget.com/itanswers/parameter-in-select-statement/#comments</comments>
		<pubDate>Mon, 04 Oct 2010 21:31:36 +0000</pubDate>
		<dc:creator>Plugsharma</dc:creator>
				<category><![CDATA[SELECT statement]]></category>
		<category><![CDATA[SQL Parameters]]></category>
		<category><![CDATA[SQL statements]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Hi, I need to pass a parameter into a stored procedure which values are dynamic always. Executing a variable which having the Select statement. Following query working fine. BEGIN DECLARE @strQuery NVARCHAR(MAX) DECLARE @CountryId INT DECLARE @CityId INT SET @CountryId = 2 SET @CityId = &#8216; AND CityId IN (23,45,85,86)&#8217; SELECT @strQuery= &#8216;SELECT VendorId From [...]]]></description>
				<content:encoded><![CDATA[<p>Hi,</p>
<p>I need to pass a parameter into a stored procedure which values are dynamic always. Executing a variable which having the Select statement.</p>
<p>Following query working fine.</p>
<p>BEGIN<br />
DECLARE @strQuery NVARCHAR(MAX)<br />
DECLARE @CountryId INT<br />
DECLARE @CityId INT</p>
<p>SET @CountryId = 2<br />
SET @CityId = &#8216; AND CityId IN (23,45,85,86)&#8217;</p>
<p>SELECT @strQuery= &#8216;SELECT VendorId From Vendors<br />
WHERE CountryId = &#8216;+@CountryId+&#8217; &#8216;+@CityId+&#8217;<br />
ORDERBY CreatedDate&#8217;</p>
<p>EXEC(@strQuery)<br />
END</p>
<p>I need to execute above in an open select statement instead of executing @strQuery.</p>
<p>Getting error as When trying through following script as &#8220;Conversion failed when converting the varchar value &#8216; AND CityId (23,45,85,86)&#8217; to data type int&#8221; </p>
<p>SELECT VendorId From Vendors<br />
WHERE CountryId = @CountryId + &#8216; &#8216; +@CityId<br />
ORDERBY CreatedDate</p>
<p>Please help me to get it working through above select statement.</p>
<p>Thanks</p>
<p>Sharma</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/itanswers/parameter-in-select-statement/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 3/30 queries in 0.031 seconds using memcached
Object Caching 916/1071 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-19 03:42:25 -->