Solved

Need help with SQL syntax error

Posted on 2008-10-16
2
239 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
Comment Utility
Try

SET @interestChildId = parentId
0
 

Author Comment

by:lapucca
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

In database programming, custom sort order seems to be necessary quite often, at least in my experience and time here at EE. Within the realm of custom sorting is the sorting of numbers and text independently (i.e., treating the numbers as number…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 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

15 Experts available now in Live!

Get 1:1 Help Now