Cursor Error

Last Post 08 Aug 2010 11:15 AM by rm. 1 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
werice
New Member
New Member

--
08 Aug 2010 10:57 AM
I have created the below cursor:
select distinct org_site_id As id,contact_id As cid,agency_hire_date As hire_date into #holdHireDate from pcaps.core.org_site_contact where agency_hire_date is not null

Declare hiredate cursor forward_only
for select id,cid,hire_date from #holdHireDate

Open hiredate

fetch hiredate

update core.org_site_contact set agency_hire_date = hire_date
where org_site_id = id
and contact_id = cid

close hiredate
deallocate hiredate
go

Why do i get the error :
Msg 207, Level 16, State 1, Line 11
Invalid column name 'id'.
Msg 207, Level 16, State 1, Line 12
Invalid column name 'cid'.

As you can see above, I do have id and cid in #holdhiredate, so why the error?
rm
New Member
New Member

--
08 Aug 2010 11:15 AM
Should declare variable for id and cid then assign value by fetch, books online has sample code under 'DECLARE CURSOR (Transact-SQL)'.
You are not authorized to post a reply.

Acceptable Use Policy