By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,766 Members | 1,281 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,766 IT Pros & Developers. It's quick & easy.

Quick question: how do I get the name of the current database?

P: n/a
Is there an sp_zzzzzz function to return the name of the current database?
I would like to use this name as a variable in a stored procedure in order
to create names for further databases (by appending a tag, such as
MYDATABASE_BLOB001, ..._BLOB002 etc.
Thanks.

Jul 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
SELECT DB_NAME()

Why create a database from a Stored Procedure?
--
David Portas
SQL Server MVP
--

Jul 23 '05 #2

P: n/a

"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:ct*******************@news.demon.co.uk...
Is there an sp_zzzzzz function to return the name of the current database?
I would like to use this name as a variable in a stored procedure in order
to create names for further databases (by appending a tag, such as
MYDATABASE_BLOB001, ..._BLOB002 etc.
Thanks.


select db_name()

It might be worth considering why you need multiple databases - could
BLOB001 be part of a key in a table instead? This discussion applies to
tables, not databases, but the principle is exactly the same:

http://www.sommarskog.se/dynamic_sql.html#Sales_yymm

Simon
Jul 23 '05 #3

P: n/a
The issue is that we have one database with our adjacency list in and then
one or more with our media blobs in. Our users won't be using full SQL
server, so we have 2Gb limit on MSDE. When one of the blob databases
reaches close to 2Gb, we rollover to the next blob database. In my
adjacency table I store the blob database ID and Key for the blob associated
with each node. I also have a table with all of the blob databases listed,
so I can lookup and find which database the ID refers to.

Can't help it. Customers are cheapskates ;)

"Simon Hayes" <sq*@hayes.ch> wrote in message
news:41**********@news.bluewin.ch...

"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:ct*******************@news.demon.co.uk...
Is there an sp_zzzzzz function to return the name of the current
database? I would like to use this name as a variable in a stored
procedure in order to create names for further databases (by appending a
tag, such as MYDATABASE_BLOB001, ..._BLOB002 etc.
Thanks.


select db_name()

It might be worth considering why you need multiple databases - could
BLOB001 be part of a key in a table instead? This discussion applies to
tables, not databases, but the principle is exactly the same:

http://www.sommarskog.se/dynamic_sql.html#Sales_yymm

Simon

Jul 23 '05 #4

P: n/a
"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:ct******************@news.demon.co.uk...
The issue is that we have one database with our adjacency list in and then
one or more with our media blobs in. Our users won't be using full SQL
server, so we have 2Gb limit on MSDE. When one of the blob databases
reaches close to 2Gb, we rollover to the next blob database. In my
adjacency table I store the blob database ID and Key for the blob associated with each node. I also have a table with all of the blob databases listed, so I can lookup and find which database the ID refers to.

Can't help it. Customers are cheapskates ;)


Something to be aware of: I think that MSDE may also limit you on the number
of databases you are allowed so there may be a limit on the number of times
you can "rollover" to another database.

Brian.

www.cryer.co.uk/brian
Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.