sql server - SQL: Must declare scalar variable -
when run following t-sql in sql server 2012 works fine, in sql server 2008 r2 error
must declare scalar variable "@in"
and
must declare scalar variable "@out"
code:
declare @outids nvarchar(max); declare @in timelinereportlist; declare @out timelinereportlist; declare @startdate datetime; declare @enddate datetime; declare @assessmentid int; set @startdate ='2013-01-01t00:00:00.000' set @enddate ='2013-01-01t00:00:00.000' set @assessmentid = 14 set @outids ='3,9,10' insert @in select * dbo.udf_first_timeline_entries_of_status(@assessmentid) insert @out select * dbo.udf_first_timeline_entries_of_any_statuses(@outids) select * dbo.udf_generic_timelines(@startdate, @enddate, @in, @out,default)
timelinereportlist
user-defined table type exists in db
edit i've tested first 2 queries running following , both return results:
select * dbo.udf_first_timeline_entries_of_status(@assessmentid) select * dbo.udf_first_timeline_entries_of_any_statuses(@outids)
as detailed comment aaron bertrand, issue due compatibility mode of database. changing compatibility 90 (sql server 2005
) fixed issue. newer features udt not supported in databases compatibility mode 80 (sql server 2000
).
for more details on effects , behavior of compatibility mode, refer thread here.
Comments
Post a Comment