Alex
Alex

Reputation: 103

DB get Current DB Name

I need to write a SQL Script in DB2 and I have to make a constraint in order for this SQL to run only on some specific DBs.

I looked online for solutions but I did not find any.

Does anybody know a way to get the name of the current connected DB?

Upvotes: 3

Views: 8969

Answers (1)

data_henrik
data_henrik

Reputation: 17118

Try this:

Select CURRENT_SERVER from sysibm.sysdummy1

The database name can be retrieved via the special register CURRENT_SERVER.

Upvotes: 4

Related Questions