Read all fields, natural sort
Declare @fields varchar(Max) Select @fields=ISNULL(@fields,"')++Name+',' fromsyscolumnsWhereId=object_id(' Contact')Order byColorderPrint @fields
Read all fields, sort by name
Declare @fields varchar(Max) Select @fields=ISNULL(@fields,"')++Name+',' fromsyscolumnsWhereId=object_id(' Contact')Order bynamePrint @fields;
Add field, change type, rename, delete field
Alter TableCompeteagentinfoAddIsfangtupayint Null, ISFANGTUint NullAlter TableContacttrailAlter columnTraildescriptionnvarchar( -) sp_rename'Contacttrail.trailisvalid','IsValid','column'ALTER TABLEtable_nameDROP COLUMNcolumn_name
Print affects the number of rows:
Print @ @rowcount
Change table name
EXEC ' SSHOP1 ' ' Shop '
Existing fields Add default values
Alter Table Add constraint DEFAULT 1 for IsValid
Find stored procedures (including Xiaobu)
SELECT from information_schema. ROUTINESWHERElike'%xiaobu%' and Routine_type= 'PROCEDURE'
[Small question note (eight)] Common SQL (read field name, change field name, print affects the number of rows, add default values, find stored procedures, etc.)