arrays - How to declare a variable containing more than one integer values SQL Server -
i want store id's in variable use variable multiple times wherever have use in queries. used format as:
declare @aid int select @aid = ap.aid sub_aminer_paper ap group ap.aid having min(p_year) = 1990 , max(ap.p_year) = 2014 , count(ap.pid) between 10 , 40 select * sub_aminer_paper aid = @aid
but gives me result single id list of id's used query retrieve multiple id's table sub_aminer_paper
.
please , thanks!
what want table variable:
declare @aid table(id int primary key) insert @aid select ap.aid sub_aminer_paper ap group ap.aid having min(p_year) = 1990 , max(ap.p_year) = 2014 , count(ap.pid) between 10 , 40 select * sub_aminer_paper aid = (select id @aid)
Comments
Post a Comment