document.write('
')

成语大全-成语接龙-成语文章-成语词典

sybase ASE通过表名和字段名查找索引名

  【IT168 服务器学院】declare @obj_name varchar(30)
  select @obj_name=''tab_name''
  select name,id,indid,keycnt into #ind from sysindexes where id= object_id(@obj_name)
  go

   declare cur cursor for select indid from #ind
   go
   declare @indid int
   declare @keycnt int
   declare @obj_name varchar(30)
   declare @col_name varchar(30)
   select @obj_name=''tab_name''
   select @col_name=''col_name''
   open cur
   fetch cur into @indid
     while @@sqlstatus = 0
         begin
           select @keycnt = min(keycnt) from #ind where indid=@indid
           while @keycnt >1
            begin
              insert into #ind select name,id,indid,@keycnt-1 from #ind where indid=@indid and keycnt=@keycnt
              select @keycnt = @keycnt -1
            end
           fetch cur into @indid
        end
  if @@sqlstatus = 2     
   begin
      deallocate cursor cur
   end
  select name from #ind where index_col(@obj_name,indid,keycnt)=@col_name
  go