- Your meritorious formation Create Table FF (aa varchar (100) Null Default '1') Go
- Modify default Declare @s nvarchar (4000) SELECT @ s = 'alter table [' b.Name '] Drop connectionT [' D.Name ']' -, table name = B.Name, field name = a.Name, default = C.Text, constraint name = D.NameFrom syscolumns a join sysobjects b on a.id = B.id Join Syscomments C on A.cdefault = C.ID Join Sysobjects D on C.ID = D.Idwhere B.Name = 'ff' and a.name = 'aa'exec (@S)
- Default value constraints for adding fields: ALTER TABLE FF ADD CONSTRAINT DF_FF_AA_112312 Default ('2') for AA
Go
- Insert a record test Insert Ff Values (Default) Select * from FFGO
DROP TABLE FF
/*--result
AA ---------------------- 2
(The number of rows affects is 1 line) - * /