开发者

Is there a variable like @@ServerName but for the database name?

I need to get the name of the database I am currently running against (to use in a URL column).

I know I 开发者_如何学JAVAcan get the server name by using @@ServerName. But there is no @@DatabaseName.

How can I get the database that is currently being run against?


Try using this:

select DB_Name()

An example where the database changes:

use master
select DB_Name()
use model
select DB_Name()


You can use DB_NAME() to get the database name.

SELECT DB_NAME() AS DataBaseName


You can use this function to get the database name which you are currently using

select DB_NAME()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜