导航
  • 主页
  • 基础类
  • 应用实例
  • 新技术前沿

在SQL中如何知道当前所运行的数据库的名字?

kewin_007 2007-11-28 09:09:21
在SQL中如何知道当前所运行的数据库的名字?(语法越详细越好!)
...全文
49 点赞 收藏 7
写回复
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
hui_hui_2007 2007-11-29

use pubs
select db_name()

--------------------------------------------------------------------------------------------------------------------------------
pubs

(所影响的行数为 1 行)
回复
w2jc 2007-11-29
学习一下
回复
rouqu 2007-11-28
没必要重复了
回复
-狙击手- 2007-11-28
name                                                                                                                             db_size       owner                                                                                                                            dbid   created     status                                                                                                                                                                                                                                                           compatibility_level 
-------------------------------------------------------------------------------------------------------------------------------- ------------- -------------------------------------------------------------------------------------------------------------------------------- ------ ----------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------
CSDN_TEST 7.56 MB sa 8 09 21 2007 Status=ONLINE, Updateability=READ_WRITE, UserAccess=MULTI_USER, Recovery=SIMPLE, Version=539, Collation=Chinese_PRC_CI_AS, SQLSortOrder=0, IsAutoShrink, IsTornPageDetectionEnabled, IsAutoCreateStatistics, IsAutoUpdateStatistics 80


name fileid filename filegroup size maxsize growth usage
-------------------------------------------------------------------------------------------------------------------------------- ------ ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------- ------------------ ------------------ ------------------ ---------
csdn_test_Data 1 C:\Program Files\Microsoft SQL Server\MSSQL\Data\CSDN_TEST_data.mdf PRIMARY 6720 KB Unlimited 10% data only
csdn_test_Log 2 C:\Program Files\Microsoft SQL Server\MSSQL\Data\CSDN_TEST_log.ldf NULL 1024 KB Unlimited 10% log only
回复
-狙击手- 2007-11-28
declare @s varchar(10)

select @s = db_name()

exec master..sp_helpdb @s
回复
zg182 2007-11-28
SELECT DB_NAME()
回复
liangCK 2007-11-28
db_name()
回复
发动态
发帖子
MS-SQL Server
创建于2007-09-28

3.2w+

社区成员

MS-SQL Server相关内容讨论专区
申请成为版主
社区公告
暂无公告