sqlserver能不能用sql语句来判断数据库里有多少表,判断某个表是否存在呢?有没有什么方法呢?
时间:2011-11-28
来源:互联网
非常感谢@!!!
作者: ciqiqi 发布时间: 2011-11-28
作者: sql_sf 发布时间: 2011-11-28
if exists (select 1 from sysobjects where name = '表名' and xtype = 'p') print 存在
作者: ssp2009 发布时间: 2011-11-28
select count(1) from sysobjects where xtype='U' if object_id('表名') is not null print '有' else print '沒'
作者: roy_88 发布时间: 2011-11-28
--1sql语句来判断数据库里有多少表 select count(*) from sys.tables --2 if object_id('数据库.架构.表') is not null print '存在' else print '不存在'
作者: Beirut 发布时间: 2011-11-28
作者: roy_88 发布时间: 2011-11-28
SQL code
if exists (select 1 from sysobjects where name = '表名' and xtype = 'p')
print 存在
作者: ssp2009 发布时间: 2011-11-28
作者: Beirut 发布时间: 2011-11-28
引用 2 楼 ssp2009 的回复:
SQL code
if exists (select 1 from sysobjects where name = '表名' and xtype = 'p')
print 存在
p改为U,p是存储过程。。。
嗯,sysobjects 是系统表吗?(本人对于数据库还很懵懂,所以不要闲我小白)
作者: ciqiqi 发布时间: 2011-11-28
作者: ssp2009 发布时间: 2011-11-28
SELECT * FROM SYSOBJECTS WHERE XTYPE='U'
作者: Sunnynanbing 发布时间: 2011-11-28
SQL code
--1sql语句来判断数据库里有多少表
select count(*) from sys.tables
--2
if object_id('数据库.架构.表') is not null
print '存在'
else
print '不存在'
我对于这方面的知识很欠缺,请问有没有什么资料可以推荐给我的,非常感谢!
作者: ciqiqi 发布时间: 2011-11-28
SQL code
select count(1) from sysobjects where xtype='U'
if object_id('表名') is not null
print '有'
else
print '沒'
我对于这方面的知识很欠缺,请问有没有什么资料可以推荐给我的,非常感谢!
作者: ciqiqi 发布时间: 2011-11-28
if object_id('表名') is not null print '有' else print '沒'
作者: fredrickhu 发布时间: 2011-11-28
引用 3 楼 roy_88 的回复:
SQL code
select count(1) from sysobjects where xtype='U'
if object_id('表名') is not null
print '有'
else
print '沒'
我对于这方面的知识很欠缺,请问有没有什么资料可以推荐给我的,非常感谢!
你想要一些什么资料 我可以贴一点点给你。
作者: fredrickhu 发布时间: 2011-11-28
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28