请问怎么查询所有的数据库的名称(不包括系统数据库)

yingoing 2010-03-28 02:06:37
在线 等
...全文
148 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
htl258_Tony 2010-03-28
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 yingoing 的回复:]
还有什么跟简单方法吗
[/Quote]
就一个查询语句,怎么查都是简单的.
v1ctory1216 2010-03-28
  • 打赏
  • 举报
回复
sp_helpdb
东那个升 2010-03-28
  • 打赏
  • 举报
回复
select * from sys.databases
where database_id>4


其实这样也可以的。
yingoing 2010-03-28
  • 打赏
  • 举报
回复
还有什么跟简单方法吗
yingoing 2010-03-28
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 ldslove 的回复:]
SQL code
select * from master..sysdatabases
where sid!=0x01
[/Quote]
这个好像不行 我是SQL 2005
东那个升 2010-03-28
  • 打赏
  • 举报
回复
select @@version


select name from master..sysdatabases
where sid!=0x01


----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Microsoft SQL Server 2008 R2 (CTP) - 10.50.1352.12 (Intel X86)
Oct 30 2009 18:22:17
Copyright (c) Microsoft Corporation
Enterprise Evaluation Edition on Windows NT 5.1 <X86> (Build 2600: Service Pack 3)


(1 行受影响)

name
--------------------------------------------------------------------------------------------------------------------------------
test
test123
Northwind

(3 行受影响)
htl258_Tony 2010-03-28
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 ldslove 的回复:]
SQL code
select * from master..sysdatabases
where sid!=0x01
[/Quote]

SQL2008 下所有的SID都是0x01
黄_瓜 2010-03-28
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 ldslove 的回复:]
SQL code
select * from master..sysdatabases
where sid!=0x01
[/Quote]
up
yhtapmys 2010-03-28
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 happycell188 的回复:]
SQL code
Select name from master..sysdatabases where name not in('master','model','msdb','tempdb','northwind','pubs')
[/Quote]

UP
2000的
htl258_Tony 2010-03-28
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 happycell188 的回复:]
SQL code
Select name from master..sysdatabases where name not in('master','model','msdb','tempdb','northwind','pubs')
[/Quote]..
--小F-- 2010-03-28
  • 打赏
  • 举报
回复
--2005
select
*
from
sys.databases
where
name not in('master','model','msdb','tempdb')
--小F-- 2010-03-28
  • 打赏
  • 举报
回复
--2005
select
*
from
sys.databases
where
name not in('master','model','msdb',tempdb')
东那个升 2010-03-28
  • 打赏
  • 举报
回复
select * from master..sysdatabases
where sid!=0x01
喜-喜 2010-03-28
  • 打赏
  • 举报
回复
Select   name   from   master..sysdatabases     where   name   not   in('master','model','msdb','tempdb','northwind','pubs') 
yingoing 2010-03-28
  • 打赏
  • 举报
回复
帮帮吗

34,873

社区成员

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

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