sqlserver判断字段是否存在,表是否存在
--创建字段[Pro_List].[Pro_Id] 创建人: 创建时间:2018-08-22 08:52:13 IF NOT EXISTS ( SELECT TOP 1 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE [TABLE_NAME] = 'Pro_List' AND [COLUMN_NAME] = 'Pro_Id' ) BEGIN ALTER TABLE Pro_List ADD Pro_Id int IDENTITY(1,1) NOT NULL EXEC sys.sp_addextendedproperty @name = N'MS_Description', @value = N'', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Pro_List', @level2type = N'COLUMN', @level2name = N'Pro_Id' END GO --创建表[SysErrorLog] 创建人: 创建时间:2018-08-22 08:52:50 IF NOT EXISTS ( SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'[SysErrorLog]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1 ) BEGIN CREATE TABLE [dbo].[SysErrorLog]( [Id] bigint IDENTITY(1,1) NOT NULL ,[Uid] int ,[ErrorNo] [nvarchar](50) ,[ErrorTitle] [nvarchar](100) ,[CreateDate] datetime ,[ErrorPage] [nvarchar](500) ,[FriendlyMsg] [nvarchar](MAX) ,[TargetSite] [nvarchar](500) ,[StackTrace] ntext CONSTRAINT [PK_SysErrorLog] PRIMARY KEY CLUSTERED ( [Id] ASC ) ON [PRIMARY] ) EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysErrorLog', @level2type=N'COLUMN',@level2name=N'Id' EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Uid' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysErrorLog', @level2type=N'COLUMN',@level2name=N'Uid' EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ErrorNo' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysErrorLog', @level2type=N'COLUMN',@level2name=N'ErrorNo' EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ErrorTitle' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysErrorLog', @level2type=N'COLUMN',@level2name=N'ErrorTitle' EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'CreateDate' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysErrorLog', @level2type=N'COLUMN',@level2name=N'CreateDate' EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ErrorPage' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysErrorLog', @level2type=N'COLUMN',@level2name=N'ErrorPage' EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'FriendlyMsg' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysErrorLog', @level2type=N'COLUMN',@level2name=N'FriendlyMsg' EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'TargetSite' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysErrorLog', @level2type=N'COLUMN',@level2name=N'TargetSite' EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'StackTrace' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysErrorLog', @level2type=N'COLUMN',@level2name=N'StackTrace' EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'SysErrorLog' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'SysErrorLog' END GO