Answer the question
In order to leave comments, you need to log in
How to create a calculated field by the value of another field in MS-SQL?
There is a pallets table, it has a shipmentid field.
It is necessary to add a calculated field shipped with a dimension of bits, where the value would be 1 when shipmentid is not null, and 0 when, respectively, null.
How to register it in alter table?
Answer the question
In order to leave comments, you need to log in
CREATE TABLE [dbo].[pallets](
[shipmentid] [int] NULL,
[shipped] AS (CONVERT([bit],case when [shipmentid] IS NULL then (0) else (1) end))
) ON [PRIMARY]
[shipped] AS (CONVERT([bit],isnull([shipmentid],(0))))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question