Wednesday, January 16, 2008

How to determine the current database in MSSQL

Today I wanted to know what database I currently was connected to in an SQL-script (since I dynamically set the database name when calling SQLCMD) and found out that there is a simple function for this: db_name()


No comments: