Hi ,
I want to update the column in a table based on the updation of the
other column in the same table, but not getting the desired result.
DDL:
CREATE TABLE [dbo].[TestTable](
[Col1] [int] NULL,
[Col2] [int] NULL,
[Col3] [int] NULL
) ON [PRIMARY]
Insert into (Col1, Col2, Col3) Values(1 , 1, 1)
Desired Result
Col1 = 2
Col2 = 3
Col3 = 4
This is the query that I'm using
update TestTable
set Col1= Col1 + 1,
Col2 = Col1 + 1,
Col3 = Col2 + 1
but the result I get is
Col1 = 2
Col2 = 2
Col3 = 2
Thanks for your help in advance.
I want to update the column in a table based on the updation of the
other column in the same table, but not getting the desired result.
DDL:
CREATE TABLE [dbo].[TestTable](
[Col1] [int] NULL,
[Col2] [int] NULL,
[Col3] [int] NULL
) ON [PRIMARY]
Insert into (Col1, Col2, Col3) Values(1 , 1, 1)
Desired Result
Col1 = 2
Col2 = 3
Col3 = 4
This is the query that I'm using
update TestTable
set Col1= Col1 + 1,
Col2 = Col1 + 1,
Col3 = Col2 + 1
but the result I get is
Col1 = 2
Col2 = 2
Col3 = 2
Thanks for your help in advance.
Comment