SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to make this a Hierarchy syntax?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Karim174
Starting Member

5 Posts

Posted - 04/19/2013 :  05:07:57  Show Profile  Reply with Quote
I'm trying to make that I have in my What'up. A hierarchical syntax

I have the following;
I have the following tables that I use for making a hierarschische group syntax; ndevicegroupID, nparentgroupID and Sgroupname. These can be found in Device Group.

Main has the following ID
ndevicegroupID nParentGroupID sgroupname
192 0 Environment

The next customer RB has a nparentgroupID and ndevicegroupID;

ndevicegroupID nparentgroupID sgroupname
45 192 RB

And the customer also has locations;
sgroupname nparentgroupid ndevicegroupid
APL 45 565

and the location has sub locations;
sgroupname nparentgroupID ndevicegroupID
Ser1a 565 566

I hope I can give to clarify enough information.

Hope that this SQL syntax to make it right.

SQL GETTING A DREAM

bandi
Flowing Fount of Yak Knowledge

India
2206 Posts

Posted - 04/19/2013 :  05:32:50  Show Profile  Reply with Quote
Hi,
Duplicate thread : (http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=184695)

Can you post sample data of tables and also expected output (Expalin the logic for output)


--
Chandu
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2206 Posts

Posted - 04/19/2013 :  05:44:14  Show Profile  Reply with Quote
You can use Recursive queries
http://blog.sqlauthority.com/2012/04/24/sql-server-introduction-to-hierarchical-query-using-a-recursive-cte-a-primer/
http://msdn.microsoft.com/en-IN/library/ms186243(v=sql.105).aspx

Someone can help you out to get the solution by knowing the expected output

--
Chandu
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000