sql server 2008 - Handling Datatype errors in dbml -
am getting unknown return type error when adding stored procedure dbml . below sp. not able figure out error. have checked many questions related , solution not use temp table.yes, not using temp table using table variable suggested blogs getting error. please help.
alter procedure dbo.reports ( @startdate datetime, @enddate datetime, @pagetype int, @assignedclincian int ) begin declare @sqlquery varchar(max) declare @strcondition varchar(max) declare @temptable table ( first_name varchar(150), last_name varchar(150), id int, pagetype_id int, rf_date datetime, dob datetime, insurancecompany varchar(250), assignedclincian varchar(250) ) set @sqlquery = 'select * tblusers' if @startdate not null , @enddate not null begin set @strcondition = ' fo.rf_date >= convert(datetime, ''' + convert(varchar,@startdate,112) + ''') , fo.rf_date<= convert(datetime, ''' + convert(varchar,@enddate,112) + ''')' end else if @startdate not null begin set @strcondition = ' fo.rf_date >=' + @startdate end else if @enddate not null begin set @strcondition = ' fo.rf_date <=' + @enddate end if @pagetype > 0 begin set @strcondition = (case when @strcondition='' '' else @strcondition + ' , ' end) + ' fo.pagetype_id='+ convert(varchar,@pagetype) end if @assignedclincian > 0 begin set @strcondition = (case when @strcondition='' '' else @strcondition + ' , ' end) +' p1.ast_clinician_assginments_to=' + convert(varchar,@assignedclincian) end set @sqlquery=(case when @strcondition='' @sqlquery else @sqlquery + ' ' + @strcondition end) + ' order fo.id' insert @temptable exec (@sqlquery) select * @temptable end return
so, after huge mess, came end solution in second elseif condition, not converting date in first if condition:
else if @startdate not null begin set @strcondition = ' fo.rf_date >=' + @startdate end
Comments
Post a Comment