use master select * from sysobjects where type='u'
declare @tn int set @tn = object_id('c') select name from syscolumns a join sysindexkeys b on a.id = b.id and a.colid = b.colid where a.id = @tn and b.indid = (select indid from sysindexes where name = (select name from sysobjects where parent_obj = @tn and xtype = 'PK'))
因为我现在要做的是要对struct里面的一个表的字段进行按序号排列,就是从‘1’开始往下排,但是输入的时候不一定是按顺序来的,可能没有2或6啊之类的,所以,我现在要重新排一下,使它递增顺序的排列。
但是这个字段现在是主键,所以我要先把主键撤消,然后排列,再添上主键,所以需要知道是主键的字段有哪些。
明白?大哥,能不能用qq啊,等的我心急,还要不时的up
select * from sysobjects
where type='u'
set @tn = object_id('c')
select name
from syscolumns a join sysindexkeys b
on a.id = b.id and a.colid = b.colid
where a.id = @tn
and b.indid = (select indid from sysindexes
where name = (select name from sysobjects
where parent_obj = @tn and xtype = 'PK'))