Build a table
/******************************************************************************** cell master record, to ensure synchronization with Orglevelunit * * * * ****************************************************************************/
IF NOT EXISTS (SELECT object_name (ID)From sysobjectsWHERE xtype =Uand OBJECTPROPERTY (Id' ismsshipped ') =0and object_name (ID) =' Wyestate ')CreateTable Wyestate (IdvarcharPrimary)KeyNotNull--Cell code, Auto code, a+4 digits, allow handwritingNamevarchar200)Null--Cell name FloorareaDecimal10,2),--Floor Area BuiltareaDecimal10,2),--Construction Area GreenareaDecimal10,2),--Green area RoadareaDecimal10,2),--Road area BuildingnumIntNotNullDefault0),--Address of building numbernvarchar2000),--Cell address Leadervarchar50),--director Leadernamevarchar100),--Owner's name Developernvarchar200),--Developer Devcontractornvarchar200),--Developer Contact person Devcontractwaynvarchar400),--Developer Contact information Remarknvarchar4000),--Remark StduservarcharNot null, Builder varchar (builddate) is not null,--Created by datetime default ( GETDATE ()) not null,--creation time Laster varchar () not null,--Last modified by person Lastdate DateTime Default (getdate ()) not null --Last modified time)
Add a table field
if not exists ( select * from syscolumns where id = object_id(‘WYEstate‘) and name = ‘MSQuestion‘ ) alter table WYEstate add MSQuestion NVARCHAR(500) null--问题
Delete a table field
if exists ( select * from syscolumns where id = object_id(‘WYEstate‘) and name = ‘MSQuestion‘ ) alter table WYEstate drop column MSQuestion--问题
Add a comment to a table field
EXEC sys.sp_addextendedproperty @name=N‘MS_Description‘, @value=N‘问题‘ , @level0type=N‘SCHEMA‘,@level0name=N‘dbo‘, @level1type=N‘TABLE‘,@level1name=N‘WYEstate‘, @level2type=N‘COLUMN‘,@level2name=N‘MSQuestion‘
SQL standard See table statement