Saturday, February 25, 2012

process all row

how would i do this in pure t-sql not in a win app
i have column A B and C all integers
psuedo sql
INSERT INTO TABLE1 (C) values (A+B)
A+B = C
thanksHoward
CREATE TABLE #Test
(
A INT,
B INT,
C AS COALESCE(A,0)+COALESCE(B,0)
)
INSERT INTO #Test SELECT 1,2
SELECT * FROM #Test
"Howard" <howdy0909@.yahoo.com> wrote in message
news:u3lkECkUGHA.776@.TK2MSFTNGP09.phx.gbl...
> how would i do this in pure t-sql not in a win app
> i have column A B and C all integers
> psuedo sql
> INSERT INTO TABLE1 (C) values (A+B)
> A+B = C
> thanks
>|||Exactly as you stated
Jack Vamvas
___________________________________
Receive free SQL tips - www.ciquery.com/sqlserver.htm
"Howard" <howdy0909@.yahoo.com> wrote in message
news:u3lkECkUGHA.776@.TK2MSFTNGP09.phx.gbl...
> how would i do this in pure t-sql not in a win app
> i have column A B and C all integers
> psuedo sql
> INSERT INTO TABLE1 (C) values (A+B)
> A+B = C
> thanks
>|||oops sorry i meant update
UPDATE table1
SET colC = colA + colB
WHERE loop all
"Jack Vamvas" <delete_this_bit_jack@.ciquery.com_delete> wrote in message
news:LfWdncfWt9dmaLXZRVnyvQ@.bt.com...
> Exactly as you stated
> --
> Jack Vamvas
> ___________________________________
> Receive free SQL tips - www.ciquery.com/sqlserver.htm
>
> "Howard" <howdy0909@.yahoo.com> wrote in message
> news:u3lkECkUGHA.776@.TK2MSFTNGP09.phx.gbl...
>|||An unrestricted update (no WHERE clause) will process the entire table.
E.g.:
UPDATE table1
SET colC = colA + colB
ML
http://milambda.blogspot.com/|||Also you dont need to have other column. Just use select
Select colA, colB, colA+colB as colC from table
Madhivanan

No comments:

Post a Comment