--sql 2k syscolumns 列信息 sysobjects 表信息 select * from syscolumns c,sysobjects o where c.id=o.id and o.name='table'
SELECT count(*) FROM syscolumns where id=(select id From sysobjects where name='table') and name='字段'如果查出的值为0时,说明‘字段’不存在
use sql 'select field_name from table; ', then catch exception..
With ADOquery1 do begin close ; sql.Clear ; sql.Add('select * from syscolumns where name = '+''''+'TEL'+''''+' and id = (select id from sysobjects where name = '+''''+'hd'+Edit1.Text+''''+')') ; open ; end ; 以上是我的原代码。判断'hd'+Edit1.Text 这个表中是否存在[TEL]字段, if ADOquery1.RecordCount = 1 then begin showmessage ('存在字段') ; end ; 明白了吗?
--sql 2k syscolumns 列信息 sysobjects 表信息 select * from syscolumns c,sysobjects o where c.id=o.id and o.name='table'
syscolumns 列信息
sysobjects 表信息
select * from syscolumns c,sysobjects o
where c.id=o.id
and o.name='table'
FROM syscolumns
where id=(select id From sysobjects where name='table') and name='字段'如果查出的值为0时,说明‘字段’不存在
begin
close ;
sql.Clear ;
sql.Add('select * from syscolumns where name = '+''''+'TEL'+''''+' and id = (select id from sysobjects where name = '+''''+'hd'+Edit1.Text+''''+')') ;
open ;
end ;
以上是我的原代码。判断'hd'+Edit1.Text 这个表中是否存在[TEL]字段,
if ADOquery1.RecordCount = 1 then
begin
showmessage ('存在字段') ;
end ;
明白了吗?
syscolumns 列信息
sysobjects 表信息
select * from syscolumns c,sysobjects o
where c.id=o.id
and o.name='table'
sysobjects 表信息
都可以查找,
当然如果你觉得复杂,在搜索出来后在query中判断也是可以的。
Table1.GetFieldNames(List: TStrings);ADO链接方式:
ADOTable1.GetFieldNames(List: TStrings);然后再在List中搜索字段就得到结果了!