Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-Server
how can get extreme right and extreme left child values in store procedure for 2nd,3rd
and above layers???
 
suppose A is Head
 
and B and C are Childs of A
 
now if B have there childs called D and E
 
And C have there childs called F and G
 
then for 2nd Layer A will consider D as his Left And G as his right so how can i get D and G values or count to increment A...
 
i have made the store procedure what changes shall i made in that..
 
here is my store procedure
 
ALTER PROCEDURE [dbo].[sp_PairMatch]
	(      
		  
		   @sponcorid varchar(50)= NULL,
		   @count_mem varchar(50)= NULL,
			@regCode varchar(50)=NULL	  
     )
AS
BEGIN
 
	
	
	--Pair Matching
SET @count_mem=0
 
WHILE(@sponcorid is not null)
	BEGIN
		SET @count_mem = (select Count(*) from Registration_Master where sponcorid=@sponcorid)
		IF(@count_mem=1)
		BEGIN
			return
		END
		
		IF(@count_mem = 2)
		BEGIN
			DECLARE @persent_Count int
			SET @persent_Count = (Select count_mem from Registration_Master where regCode=@sponcorid)
   			SET @persent_Count=@persent_Count+1
			UPDATE Registration_Master SET count_mem=@persent_Count where regCode=@sponcorid
 
			DECLARE @temp varchar(50)
			SET @temp=@sponcorid
			set @sponcorid = (SELECT sponcorid from Registration_Master WHERE regCode=@temp )
			
--			IF((@count_mem >=20) AND (@count_mem<40))
--			BEGIN
--				UPDATE Registration_Master SET @member_status='MANAGER' where sponcorid=@sponcorid   
--			END
		END
 
END
 
END
 
SELECT * FROM Registration_Master WHERE regCode=@regCode
 
{´[edit]code block added[/edit]
Posted 13-Nov-12 3:51am
Edited 13-Nov-12 13:20pm
47.5K
v3
Comments
ryanb31 at 13-Nov-12 9:54am
   
Without showing us anything, how can we help?
Marcus Kramer at 13-Nov-12 9:55am
   
You'll have to provide a little more information, perhaps a db schema and such would help.
damodara naidu betha at 14-Nov-12 0:19am
   
how to show the output? and please provide the sample data and table structure...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 355
1 _Amy 235
2 Peter Leow 185
3 Andreas Gieriet 180
4 Dave Kreskowiak 155
0 OriginalGriff 7,540
1 Sergey Alexandrovich Kryukov 6,462
2 Maciej Los 3,849
3 Peter Leow 3,653
4 CHill60 2,712


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 13 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100