getting current database name

getting current database name

Post by dd » Thu, 16 Nov 2000 05:31:06



Hi,

I am using Omnis 7 and need to execute an SQL command to return the current
SQL SERVER database name that I am already connected to. Omnis is not a
factor as it executes SQL commands as would any other language.

DD

 
 
 

getting current database name

Post by Dean McCra » Thu, 16 Nov 2000 04:00:00


If you have access to the ODBC API from your environment, then it is the
SQLGetConnectionAttr() function with the SQL_ATTR_CURRENT_CATALOG attribute.

In SQL you can use something like (cast/column name to what you like or not
at all):

SELECT CAST (SD.[name] AS NVARCHAR(128)) AS "Database Name"
FROM [master].[dbo].[sysprocesses] AS SP
JOIN [master].[dbo].[sysdatabases] AS SD ON (SP.dbid = SD.dbid)

Dean.


> Hi,

> I am using Omnis 7 and need to execute an SQL command to return the
current
> SQL SERVER database name that I am already connected to. Omnis is not a
> factor as it executes SQL commands as would any other language.

> DD