lapucca
asked on
Need help with SQL syntax error
Hi, I'm getting sytax error for the line:
@interestChildId = parentId
Msg 102, Level 15, State 1, Procedure GetData, Line 63
Incorrect syntax near '@interestChildId'.
It's been a while since I write query. Appreciate some help here. Thank you.
@interestChildId = parentId
Msg 102, Level 15, State 1, Procedure GetData, Line 63
Incorrect syntax near '@interestChildId'.
It's been a while since I write query. Appreciate some help here. Thank you.
DECLARE @interestChildId bigint;
Declare curApplicationRow Cursor FOR
SELECT RchChildId from NewApplication
Open curApplicationRow
FETCH NEXT FROM curApplicationRow
INTO @interestChildId
WHILE @@FETCH_STATUS =0 --GO THROUGH EACH RECORD
BEGIN
SELECT dbo.ResearchInterests.Name as interestName, dbo.ResearchInterests.ParentResearchInterest_id as parentId
from dbo.ResearchInterests
WHERE dbo.ResearchInterests.Id = @interestChildId
WHILE(parentId <> NULL)--USE THE PARENTID TO TRAVERSE TO ITS PARENT NODE UNTIL REACHES ROOT NODE
BEGIN
@interestChildId = parentId
SELECT dbo.ResearchInterests.Name, dbo.ResearchInterests.ParentResearchInterest_id as parentId
from dbo.ResearchInterests
WHERE dbo.ResearchInterests.Id = @interestChildId
END
FETCH NEXT FROM curApplicationRow
INTO @interestChildId
END
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER