How to put column values in variables in SQL Server -


i have sql server table #sqldata following column splitdata.

splitdata --------- bb10_1_x 4759 566549 

i want store these 3 column values 3 different variables. please me beginner , don't know how it..

you can declare variables this:

declare @var varchar(max)  

and can assign them using select statement this:

select @var=mycolumn  mytable  <my condition> 

there plenty of resources on tsql if google it.

in situation, if you're sure have 3 rows, can use 3 separate select statements:

declare @var1 varchar(max), @var2 varchar(max), @var3 varchar(max)  select @var1=mycolumn  mytable  <my condition returns first row>  select @var2=mycolumn  mytable  <my condition returns second row>  select @var3=mycolumn  mytable  <my condition returns third row> 

Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -