When writing SQL queries, there is a performance benefit to be had from qualifying the database schema (e.g. select fooField from dbo.fooTable).

I recently worked on a system where all SQL code was qualified with the database name – e.g. DatabaseName.Schema.TableName.

This in esscence is not a terrible idea – After all, it provides surity that we will always select from the correct database, but,  what happens we we want to rename the database? “I’ll never do that!” No? How about when you have a development copy on a server, and decide you want a second copy on the same server for some reason – Maybe testing two scenarios/builds, testing one one version whilst forward development occurs on the 2nd? Plus probably numerous other scenarios.

Basically – Don’t do it. I see no good reason for qualifying the database name in queries, although as ever I am open to friendly debate via comments!

Advertisements
%d bloggers like this: