在sql7的存储过程中如何判断表中的一字段是否存在?(100分)

  • 主题发起人 主题发起人 goujie
  • 开始时间 开始时间
G

goujie

Unregistered / Unconfirmed
GUEST, unregistred user!
在sql7的存储过程中如何判断表中的一字段是否存在?
 
sysobjects 存放表名
syscolumns 存放列名
在sql7的存储过程中如何判断 Aa 表中的一 Bb 字段是否存在?
select * form (select a.name as 表名 ,b.name as 列名 form sysobjects a ,syscolumns b where a.id =b.id) c
where c.表名=“Aa” and c.列名=“Bb”
if @@rowcount=1 then findit


 
sysobjects 存放表名
syscolumns 存放列名
在sql7的存储过程中如何判断 Test 表中的一 name 字段是否存在?
select * from syscolumns
where id in (select id from sysobjects where name = 'Test')
and name = 'name'
 
if Exists (select * from (select sysobjects.name as 表名 ,syscolumns.name as 列名 from sysobjects,syscolumns where sysobjects.id =syscolumns.id) report_zycxj_tj
where report_zycxj_tj.表名='report_zycxj_tj' and report_zycxj_tj.列名='发卡')
print 'Have!'
else
begin
print 'No Have!'
alter table report_zycxj_tj add 发卡 float default 0.00
end
select * from report_zycxj_tj
 
多人接受答案了。
 
后退
顶部