PLs could somebody tell me how in MS SQL set the default value of a column as the sum of 2 columns

column3=column1+column2
where column3 is bigint
column1 and column2 are int
column1 is primary key with identity incresed by 1

if posibble column2 is a column from another table but the same db
Thanks a lot

PLs could somebody tell me how in MS SQL set the default value of a column as the sum of 2 columns

column3=column1+column2
where column3 is bigint
column1 and column2 are int
column1 is primary key with identity incresed by 1

if posibble column2 is a column from another table but the same db
Thanks a lot

you can write a trigger on a table for insert update
and dotn pass the value for field, so whever u will enter the row or alter it, the next field which is formula will be generated automatically,
if u r unknown for triggers then inform me
i will tell u ow to make triggers

I would go with the simpler computed column

CREATE TABLE [TableName] (
	[Column1Name] [int] IDENTITY (1, 1) NOT NULL ,
	[Column2Name] [int] NULL ,
	[Column3Name] AS ([Column1Name] + [Column2Name]) 
) ON [PRIMARY]
GO
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.