求一条简单的语句,先到先得.....

subufan 2012-10-08 10:29:53
如何选出表名中含有“node_001”的表呢?
...全文
220 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
Acoll 2012-10-16
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 的回复:]

可是。。我查询不出来任何结果,我说的再详细一点吧,
我数据库里的表名:
node_002_co2concn
node_002_winddirection
node_003_temperature
如何查询出来带有node_002_...的表呢。。谢谢大家啦
[/Quote]

SELECT * FROM sysobjects s WHERE s.[type]='U' AND [name] LIKE 'node_002_%'其实很简单啊,like关键字已经提供了强大的模糊查询功能了。
subufan 2012-10-16
  • 打赏
  • 举报
回复
可是。。我查询不出来任何结果,我说的再详细一点吧,
我数据库里的表名:
node_002_co2concn
node_002_winddirection
node_003_temperature
如何查询出来带有node_002_...的表呢。。谢谢大家啦
kate_1988 2012-10-11
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 的回复:]

SQL code

select * from databaseName.dbo.sysobjects where type='U' and name like '%node_001%'

--和楼上的区别是加上数据库名称
[/Quote]
赞一个
husang608 2012-10-09
  • 打赏
  • 举报
回复
select *  from databaseName.dbo.sysobjects where type='U' and name like '%node_001%'
我腫了 2012-10-09
  • 打赏
  • 举报
回复
USE test
GO

IF object_id('tempdb..#') IS NOT NULL
DROP TABLE #
CREATE TABLE # (databases sysname,tabels sysname)

--搜索所有數據庫
INSERT INTO #
EXEC sys.sp_MSforeachdb
@command1=N'select ''?'' as databases,name as tables from ?.sys.sysobjects where type=''U'' and name like ''%node_001%'''

SELECT * FROM #


IF object_id('tempdb..#') IS NOT NULL
DROP TABLE #
dodolzc10 2012-10-08
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]
SQL code

select * from sysobjects where type='U' and name like '%node_001%'
[/Quote]
请问type='U'什么意思
-Tracy-McGrady- 2012-10-08
  • 打赏
  • 举报
回复

select * from databaseName.dbo.sysobjects where type='U' and name like '%node_001%'

--和楼上的区别是加上数据库名称
以学习为目的 2012-10-08
  • 打赏
  • 举报
回复
select *  from sysobjects where type='U' and name like '%node_001%'
以学习为目的 2012-10-08
  • 打赏
  • 举报
回复
select *  from sys.objects where type='U' and name like '%node_001%'
發糞塗牆 2012-10-08
  • 打赏
  • 举报
回复
我也来
select * from sys.tables where name like '%node_001%'
以学习为目的 2012-10-08
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 的回复:]

引用 2 楼 的回复:
SQL code

select * from sysobjects where type='U' and name like '%node_001%'

请问type='U'什么意思
[/Quote]

是确定对象类型,type对应的P是存储过程、V是视图...

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧