# Tuesday, May 16, 2006
« A change of directions... | Main | New feature in .Net 2.0 Exception object... »

Still working on getting posts over at developernation.net, and ran out of time on a series I am writing. This week looks to slow down a bit, so hopefully by the end of the week I can finish my series on a web service for paging and sorting data. Until then, I just ran across a situation where I needed to programmatically determine the current database name from T-SQL. Sounds easy, right? Well, fortunately it is, but the function to do it is documented poorly, so I figured I would post a tip so others could find it easily.

SELECT db_name()

The documentation says you need to pass in the db id, as does the example. However, if you read very closely, it appears you don't need to pass in the id, and it will return the current db for the connection. I wish they would have followed the documentation standard of using optional parameters with brackets [], and it would have saved some time.