September 24, 2018 at 7:40 am
hi experts,
I have one simple question here about update the value using query itself as shown below.
is there a simple way to update Volume column using query column?
first 4 rows will return same value,
thanks
Austin
September 24, 2018 at 8:07 am
Im thinking add seq number to the table and using seq to update each row in the table but am not sure. any suggestion?
declare @seq int =1
declare @seq_max int = (select max(seq) from [AdventureWorksDW2008R2].[dbo].[test])
declare @sql varchar(max)= (select query from [AdventureWorksDW2008R2].[dbo].[test] where seq = @seq)
while (@seq <= @seq_max)
update a
set a.volume = ??????
from [AdventureWorksDW2008R2].[dbo].[test]a
where seq = @seq
@seq =@seq +1
September 24, 2018 at 8:54 am
caojunhe24 - Monday, September 24, 2018 7:40 AMhi experts,I have one simple question here about update the value using query itself as shown below.
is there a simple way to update Volume column using query column?first 4 rows will return same value,
thanks
Austin
Please define exactly what content you want in the [volume] column and how it's derived.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 24, 2018 at 11:08 am
Hi guru,
the volume should be float value and it's derived from query column{select count(*) from ..}
e.g in the first row if you excute the select query from [query] column it will have 20 this 20 should be in [Volume] column.
thanks
Austin
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy