Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
ALTER FUNCTION [vainimarketing].[dbo.Countnode](@node AS varchar(50))
Returns INT
AS
BEGIN
Declare @lnode Varchar(50)
Declare @rnode Varchar(50)
Declare @result INT
Select @lnode=LeftChild,@rnode=RightChild From Tree where ParentId=@node;
if(@lnode=0 AND @rnode=0)
begin
Set @result=1;
end
else
begin
set @result=1+(dbo.Countnode(@lnode)+dbo.Countnode(@rnode));
end
return @result;
END


stored procedure
C#
set @lcount= vainimarketing.dbo.Countnode(@lchild);
set @rcount= vainimarketing.dbo.Countnode(@Rchild);
Posted
Updated 17-Dec-12 1:35am
v2
Comments
Herman<T>.Instance 17-Dec-12 7:37am    
and the problem is?
ZurdoDev 17-Dec-12 8:19am    
What's the question?

1 solution

try this:

C#
select @lcount= vainimarketing.dbo.Countnode(@lchild);
select @rcount= vainimarketing.dbo.Countnode(@Rchild);
 
Share this answer
 
Comments
rajan1189 18-Dec-12 0:26am    
Cannot find either column "dbo" or the user-defined function or aggregate "dbo.Countnode", or the name is ambiguous

please help me out from this,,thanks in advance..
ss29101976 18-Dec-12 9:21am    
Hi,

can you run below code on SQL Mgmt studio and let me know what you get.

Declare @lnode Varchar(50)
Declare @rnode Varchar(50)

set @lnode = '30' -- assign valid id to see the results.
set @rnode = '30' -- assign valid id to see the results.

select @lcount= dbo.Countnode(@lchild);
select @rcount= dbo.Countnode(@Rchild);

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900