troubleshooting Question

Problem to the line

Avatar of Peter Chan
Peter ChanFlag for Hong Kong asked on
DatabasesMicrosoft SQL ServerMicrosoft Legacy OS
41 Comments1 Solution356 ViewsLast Modified:
How to correct the last exec line below
declare @objcursor as cursor 
	@iteStatus nvarchar(2),
	@ite2tatus nvarchar(2),
	@vsql nvarchar(max),
	@vquery nvarchar(max),
	@unit nvarchar(10),
	@featNo nvarchar(10)
	set @vquery = 'select c.iteStatus,c.ite2tatus,c.unit,c.featNo from '+@tab_nm+' i,obj2 a,objs c where isnull(i.EVENT_TYPE,'''') '
		+'in(''A'',''D'',''M'') and isnull(i.UPDATE_STATUS,'''')=''R'' and i.obj_UNIT=a.Unit and i.obj2No=a.obj2No '
		+'and a.UNIT=c.Unit and a.featNo=c.featNo order by i.EVENT_TIMESTAMP'
	set @vsql = 'set @cursor = cursor forward_only static for ' + @vquery + ' open @cursor;'
	exec sys.sp_executesql
		,N'@cursor cursor output'
		,@objcursor output

due to this error?
Msg 16950, Level 16, State 2, Procedure p_upd_cust_status, Line 22
The variable '@objcursor' does not currently have a cursor allocated to it.

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 41 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 41 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros