First, SQL Modify field default value
- ALTER TABLE name DROP CONSTRAINT constraint name
- Description: Delete the original constraint for a table field
- ALTER TABLE name ADD constraint constraint first name default value for field name
- Description: Add a constraint for a table's field and specify a default value
- Go
Cases:
- ALTER TABLE t_ping DROP constraint Df_t_ping_p_c
- ALTER TABLE t_ping add constraint Df_t_ping_p_c DEFAULT ((2)) for P_c
- Go
Second, get the field default value
- Select B.text as Default field name (Random)
- From syscolumns a LEFT join syscomments B on a.cdefault=b.id
- where a.id=object_id (' table name ') and a.name= ' field name '
Description: syscolumns, syscomments for system table
Cases:
- Select B.text as Moren
- From syscolumns a LEFT join syscomments B on a.cdefault=b.id
- where a.id=object_id (' t_ping ') and a.name= ' P_c '
After getting the quotation marks, you can intercept the characters
SQL Modify field Default value