Opening Cursor tcQueryString=SELECT dbo.co_lu_Ident.recordid,dbo.co_lu_Ident.idtype, ISNULL(dbo.co_pat_ID.answerflag,0) as answerflag, ISNULL(co_pat_id.pat_id_ID,0) as patidid FROM dbo.co_lu_Ident LEFT OUTER JOIN dbo.co_Pat_ID ON dbo.co_lu_Ident.recordid = dbo.co_pat_ID.RecordID and co_Pat_ID.meetingnumber=@tiMeetID Server: Msg 137, Level 15, State 2, Line 5 Must declare the variable '@tiMeetID'.Here is the code in the stored procedure:
CREATE PROCEDURE ct_Get_Note_ListItems @tiNoteID int, @gnMeetID int as declare @tiMeetID int set @tiMeetID=@gnMeetID declare c cursor local for select isnull(querystring,' ') as QueryString from NoteControlQueries where noteid=@tiNoteID print 'Opening Cursor' Open c declare @tcQueryString varchar(4000) fetch c into @tcQueryString close c print 'tcQueryString=' + @tcQueryString exec(@tcQueryString)Thanks for any help