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
Post a Comment