--设置主键
--alter table 你的表名 add constraint pk_s primary key (id)
SELECT 'alter table ' + TABLE_NAME + ' add constraint PK_'+TABLE_NAME +'_'+ COLUMN_NAME + ' primary key ('+COLUMN_NAME+') ;'
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME='Id' order by TABLE_NAME;