一定要用delphi中的query来查询,不用table

解决方案 »

  1.   

    select a.name from syscolumns a,sysobjects b
    where b.name='tablename' and a.id=b.id
      

  2.   

    其中a是你要返回的字段名的tablename是吗,b是什么意思呢
      

  3.   

    a.name是字段名称,b是sysobjects的别名
      

  4.   

    那我在把返回的值放到combobox中combobox.item.add()刮号内的语句该怎么写呢是不是设一个变量i等于零select 后的值用recordcount和一个循环把它符到combobox1的items中
      

  5.   

    :gettable
      select TableName=o.name ,SystemObj = (case 
                   when (OBJECTPROPERTY(o.id, N'IsMSShipped')=1) then 1 
                   else OBJECTPROPERTY(o.id, N'IsSystemTable') end)
      into #Temp1
      from dbo.sysobjects o, dbo.sysindexes i 
      where OBJECTPROPERTY(o.id, N'IsTable') = 1 and i.id = o.id 
            and i.indid < 2 and o.name not like N'#%'   order by TableName
      select TableName from #Temp1 where SystemObj=0:getviewer
      select o.name,SysObj=ISNULL(OBJECTPROPERTY(o.id, N'IsMSShipped'), 1)
      into #Temp1
      from dbo.sysobjects o 
      where OBJECTPROPERTY(o.id, N'IsView') = 1 and o.name not like N'#%%'  
      order by o.name
      select TableName=[Name] from #Temp1 where SysObj=0:getcolumn
    select c.name,c.ColID,Type=d.Name,Length=c.Length,Prec=c.xPrec,Scale=c.xScale,c.colid
     from syscolumns c,dbo.systypes d 
    where id=object_id(@TableName) and c.xusertype=d.xusertype
    :getcolumnExt
      select ColumnName=c.name, p.value
      into #Temp1
      from dbo.sysproperties p, dbo.syscolumns c 
      where p.type = 4 and p.id = c.id and p.smallid = c.colid and 
         c.id = object_id(@TableName)
      if LTrim(RTrim(@ColumnName))<>''
        select * from #Temp1 
             where Upper(LTrim(RTrim(ColumnName)))=Upper(LTrim(RTrim(@ColumnName)))
      else
        select * from #Temp1 
      

  6.   

    很简单:Query1.Close;
    Query1.SQL.Clear;
    //你并不需要真正获得记录,所以条件为1=0
    Query1.SQL.Add('select * from 表名 where 1=0'); 
    Query1.Open;for iLoop:=0 to Query1.FieldCount-1 do
    begin
      //将数据表的字段名添加到TListBox1列表框中
      ListBox1.Items.Add(Query1.Fields[iLoop].FieldName); 
    end;Query1.Close