sql添加表列字段描述添加默认值删除字段

时间:2021-06-26 05:15:50
【文件属性】:

文件名称:sql添加表列字段描述添加默认值删除字段

文件大小:4KB

文件格式:TXT

更新时间:2021-06-26 05:15:50

SQL

sql添加表列字段描述添加默认值删除字段 //删除表 if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[JHCRM_Report_ss]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [JHCRM_Report_ss] //添加表 if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Table1]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) create table [Table1] ([col1] int,[col2] int) //添加字段 if not exists( select * from syscolumns where syscolumns.[name]='FNewObjectEnd' and syscolumns.[id]=(select id from dbo.sysobjects where id=object_id(N'[dbo].[jsc_financial]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) ) ALTER TABLE jsc_financial ADD FNewObjectEnd int--NULL --添加先用项目结项数 go EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'先用项目结项数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'jsc_financial', @level2type=N'COLUMN',@level2name=N'FNewObjectEnd' if not exists( select * from syscolumns where syscolumns.[name]='Record_Money' and syscolumns.[id]=(select id from dbo.sysobjects where id=object_id(N'[dbo].[JHCRM_Resource_Record_Main]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) ) ALTER TABLE JHCRM_Resource_Record_Main ADD Record_Money numeric(12, 2)--NULL --资源费用 go EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'资源费用' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'JHCRM_Resource_Record_Main', @level2type=N'COLUMN',@level2name=N'Record_Money' //删除字段 if not exists( select * from syscolumns where syscolumns.[name]=table_Name and syscolumns.[id]=(select id from dbo.sysobjects where id=object_id(N'[dbo].[tableName]')" and OBJECTPROPERTY(id, N'IsUserTable') = 1) ) ALTER TABLE table_Name DROP COLUMN tableName


网友评论