Set identity_insert [DBO]. [t_message] oninsert into [DBO]. [t_message] (f_mid) values (55)
Set identity_insert [DBO]. [t_message] offgoselect * from [DBO]. [t_message] order by f_mid DESC identify sequence DBCC checkident ('t_member ', reseed, @ identity)
Primary Key
View code
select name from sysobjects where parent_obj=object_id('abc') and xtype='pk'alter table abc add constraint PK_bbb primary key(bbb)alter table abc drop constraint PK_bbb
Id Modification
View code
Four steps: 1. Add an int-type alter table add xinglie Int. 2. Update the data in the new column to the auto-incrementing column. Update TB set xinglie = auto-incrementing column name. 3. Delete the auto-incrementing column alter table tb. drop column auto-incrementing column 4. Change the new column name to the original auto-incrementing column name exec sp_rename n'tb. xinglie ', 'original auto-incrementing column name', n' column'
Default Value
-- Note: alter table abc drop constraint df_bbb, the original constraint for deleting table fields -- Note: add a table field constraint and specify the default value alter table abc add constraint df_ccc default 5 for CCC -- the default value of the table field select B. text as DF from syscolumns a left join syscomments B on. cdefault = B. ID where. id = object_id ('abc') and. name = 'ccc '-- constraints on the default values of the query table fields select B. name,. * From sysobjects A, syscolumns bwhere. id = B. cdefault and. parent_obj = object_id ('abc') and. xtype = 'D' and B. name = 'ccc'