USE EDW_Atomic;
IF NOT EXISTS
(
SELECT t.name TableName
,C.name ColumnName
FROM SysColumns C
INNER JOIN sys.objects T
ON C.id = T.object_id
WHERE C.name = 'Rx_PART_BD_IND' --FieldName
AND T.name = 'RX_CLAIM_DETAIL' --TableName
)
ALTER TABLE dbo.RX_CLAIM_DETAIL ADD Rx_PART_BD_IND VARCHAR(1) NULL;
1,一定要写 use 某个数据库
2,一定要先判断是否已存在这个字段
SQL之-建库、建表、建约束、关系、部分T-sql语句