﻿<?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 / SQL Server 2008 - General  / How to get ParentID / 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>Thu, 23 May 2013 12:38:50 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: How to get ParentID</title><link>http://www.sqlservercentral.com/Forums/Topic1073973-391-1.aspx</link><description>You'll need a recursive CTE for that.This MSDN article explains the concept:[url]http://msdn.microsoft.com/en-us/library/ms186243.aspx[/url]</description><pubDate>Mon, 07 Mar 2011 03:41:29 GMT</pubDate><dc:creator>Koen Verbeeck</dc:creator></item><item><title>How to get ParentID</title><link>http://www.sqlservercentral.com/Forums/Topic1073973-391-1.aspx</link><description>I am using sql server 2008 enterprise editionI have Account Table like this.AccountID    Name                ParentID1                Account               02                Asset                  03               Expensess            14               Building                25               Income                16              Small Expenses       37              small Income          58              Furniture               4and so onIf i got 0 then that is main account.until we have to search it has to get.All accounts related to parent accounts Account and Asset onlyif i am retrieving account id=7then out put is like thisAccountID    Name                ParentAccountName     7              small Income       Accountif i am retrieving account id=8then out put is like thisAccountID    Name                ParentAccountName    8              Furniture             AssetLike this i have to get output.How to write Query for thisThank's in Advance</description><pubDate>Mon, 07 Mar 2011 00:55:08 GMT</pubDate><dc:creator>ranga.402</dc:creator></item></channel></rss>