How do i find out in sql what db name I'm connect to
Posted
by gjutras
on Stack Overflow
See other posts from Stack Overflow
or by gjutras
Published on 2010-05-25T14:10:05Z
Indexed on
2010/05/25
14:11 UTC
Read the original article
Hit count: 165
We have a change control environment where the developers give scripts to change control people to run. we have dev,qa, & production environments.
I want to conditionalize a couple segments to do some different things depending on what database the change control person is running my script.
If @dbname='dev'
then
begin
--do some dev stuff
end
If @dbname='QA'
then
begin
--do some qa stuff
end
If @dbname='Prod'
then
begin
--do some production stuff
end
How do I get at what the current connected database is and fill @dbname?
© Stack Overflow or respective owner