Solved

Need help with SQL syntax error

Posted on 2008-10-16
2
241 Views
Last Modified: 2012-05-05
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.




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

Open in new window

0
Comment
Question by:lapucca
2 Comments
 
LVL 39

Accepted Solution

by:
Roger Baklund earned 500 total points
ID: 22737007
Try

SET @interestChildId = parentId
0
 

Author Comment

by:lapucca
ID: 22737016
Yap!  That did the trick.  It's been a few years since I write queries.  I know what I want just can't remember all the syntax.  Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now