dbo .. syntax and the default database

In this post I’m going to discuss sql server’s dbo .. syntax.  Truth be told, it isn’t rocket science.  ‘..’ can be used as a replacement for dbo when referring to the default schema in a tsql query.  If you need to access the default database frequenty, the dbo .. syntax shortcut can greatly increase your efficiency.  If you don’t use the dbo syntax very often then this may not help you too much but it does give you another way to brag to your programmer friends about how awesome you are.

In the following example I’ve made the assumption the default database is AdventureWorks2008.  Your default database is likely to be different.  To learn how to find the default database for a given login please see the post here.

SQL

SELECT * FROM AdventureWorks2008.dbo.AWBuildVersion; -- if the default schema is AdventureWorks2008 then -- the following is the same as the fully qualified -- table name given on line one. SELECT * FROM ..AWBuildVersion;

Output

SystemInformationID Database Version          VersionDate             ModifiedDate
------------------- ------------------------- ----------------------- -----------------------
1                   10.50.91013.00            2009-10-13 00:00:00.000 2009-10-13 00:00:00.000

(1 row(s) affected)

SystemInformationID Database Version          VersionDate             ModifiedDate
------------------- ------------------------- ----------------------- -----------------------
1                   10.50.91013.00            2009-10-13 00:00:00.000 2009-10-13 00:00:00.000

(1 row(s) affected)