Looking for a database name query in SQL

Tags:
Database
Query
SQL
SQL Query
SQL Server
Is there a query in SQL that could return me the name of a database, or whether it is connected to SQL Server or Oracle?

Answer Wiki

Thanks. We'll let you know when a new response is added.

If you run the following query on SQL Server it will tell you the name of the database you are in.

<pre>SELECT db_name()</pre>

As fr as I know there is no code that can be run on both SQL Server and Oracle to find out what platform you are connected to.

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Denny Cherry
    Check out my SQL Server blog "SQL Server with Mr Denny" for more SQL Server information.
    66,010 pointsBadges:
    report
  • Ritchie1
    To see if Oracle or SQL Server are running check each's version - one will return an answer the other will cause an error. Handle the error - and you know if it is Oracle or SQL Server. To determine which version of Microsoft SQL Server: SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition') To determine which version of Oracle: select * from v$version where banner like 'Oracle%'; It should return something like this: Oracle9i Enterprise Edition Release 9.2.0.1.0 - 64bit Production
    210 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following