您的位置:首页 > 数据库

判断表是否存在或表是否有数据的sql语句

2012-02-06 19:23 477 查看
 
use pubs

go

if(select count(*) from authors )=0

begin

 print 'no data'

end

else

begin

 print 'has data'

end

go

IF NOT EXISTS ( select name from sysobjects where type ='U' and id = object_id('tablename'))

begin

print 'not exist'

end

else

begin

print 'exist'

end

go

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  sql object