Home Forums SQL Server 2005 SQL Server Newbies How to add two column and the to put the result on the next row? RE: How to add two column and the to put the result on the next row?

  • Hi angjoni,

    You can use below code to perform this operation:

    create table test99 (column1 int, column2 int, result int)

    insert into test99

    values

    (50,1500,0),

    (100,0,0),

    (40,0,0),

    (30,0,0)

    declare @col2 int = 1500

    select * from test99

    update test99

    set @col2 = result = @col2 + column1,

    column2 = @col2

    from test99

    select * from test99

    drop table test99