How a Variable Holds Numbers of Values in SQL

--How does a variable holds numbers of values in SQL?

--How to store numbers of values with the same data type in one variable?
-- I have given this example to clear your concept
.

select * from employee //is table

-------------------------------------------------------------------------------------------------------------------------

Declare @IDNUMBER Table(ID int); //First declare variable as table

insert into @IDNUMBER(ID) select distinct id from employee //insert into that table according to you requirement

//and use that variable into your where condition

Select ID, ENAME , DOB, AGE from employee where ID in (select ID from @IDNUMBER)

Ebook Download
View all
Learn
View all