给Table加字段的SQL
/****** Table Update ******/
IF EXISTS(
SELECT 1 FROM syscolumns
WHERE id = object_id('bp_list_detail')
AND name = 'additional_cost'
)
BEGIN
PRINT 'This column has exist!'
END
ELSE
BEGIN
ALTER TABLE [dbo].[bp_list_detail]
ADD [additional_cost] [decimal](18, 4) DEFAULT (0) NOT NULL
EXEC sp_addextendedproperty N'MS_Description', N'', N'user',
N'dbo', N'table', N'bp_list_detail', N'column',N'additional_cost'
END
GO
IF EXISTS(
SELECT 1 FROM syscolumns
WHERE id = object_id('bp_list_detail')
AND name = 'additional_cost'
)
BEGIN
PRINT 'This column has exist!'
END
ELSE
BEGIN
ALTER TABLE [dbo].[bp_list_detail]
ADD [additional_cost] [decimal](18, 4) DEFAULT (0) NOT NULL
EXEC sp_addextendedproperty N'MS_Description', N'', N'user',
N'dbo', N'table', N'bp_list_detail', N'column',N'additional_cost'
END
GO