: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
很简单: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
where b.name='tablename' and a.id=b.id
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
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