我已将三个表合并为一个表,并且我注意到每个合并表都有相似的数据列,从而产生冗余。
将所有这些列更新为一列的最佳方法是什么?
现在数据将读取
WallJambHeadCut | WallJambSillCut | DoorJambSillCut | DoorJambHeadCut | ect ....
1 0 0 0
0 0 1 0
以上内容也需要浓缩为两列:
Headcut | SillCut
换句话说,这些列中的每一列都可以浓缩为一列。我只是想确保我编写了正确的更新语句,因为我讨厌将我的数据提取出来。
CREATE TABLE [dbo].[Table_1](
[ID] [int] IDENTITY(1,1) NOT NULL,
[WallJambHeadCut] [bit] NOT NULL,
[WallJambSillCut] [bit] NOT NULL,
[DoorJambSillCut] [bit] NOT NULL,
[DoorJambHeadCut] [bit] NOT NULL,
[VerticalHeadCut] [bit] NOT NULL,
[VerticalSillCut] [bit] NOT NULL,
CONSTRAINT [PK_Table_1] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]