那位高手能写出SQL 谢谢了

解决方案 »

  1.   

    select name from syscolumns a where exists (
    select * from sysindexkeys b where b.id=object_id(N'表名') and a.id=b.id and a.colid=b.colid)
      

  2.   

    select name 
    from syscolumns a 
    where exists (
              select * from sysindexkeys b 
              where b.id=object_id(N'tb1') 
                    and a.id=b.id and a.colid=b.colid
                 )
      

  3.   

    select a.[name], c.[name]
    from sysobjects a join sysindexkeys b on a.[id] = b.[id]
    join syscolumns c on b.[id] = c.[id] and b.colid = c.colid
    where a.type = 'U' and b.indid = 1
      

  4.   

    select 列名=(select name from syscolumns where id=b.id and colid=c.colid),
    主键名=a.name
    from sysobjects a,sysindexes b,sysindexkeys c 
    where a.xtype='pk' and a.name=b.name and b.id=c.id and b.indid=c.indid and 
    b.id=OBJECT_ID(N'h_info')