Sunday, February 19, 2012

adding dbo before tablename

Hi all
What is the impact of adding dbo with tablename
for example
select * from dbo. table1
instead of
select * from table1
does adding dbo before table1 makes any benefit?
ThanksHi
"Worst Practice - Not Qualifying Objects With The Owner"
http://www.sqlservercentral.com/col...iththeowner.asp
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"AM" <anonymous@.examnotes.net> wrote in message
news:O5mRGu4SFHA.3176@.TK2MSFTNGP09.phx.gbl...
> Hi all
> What is the impact of adding dbo with tablename
> for example
> select * from dbo. table1
> instead of
> select * from table1
> does adding dbo before table1 makes any benefit?
> Thanks
>
>
>
>|||If I'm not mistaken, there is a slight performance improvement by designatin
g
the owner name in that the system does not have to guess. The system will fi
rst
try: username.Table1 and if that doesn't work it will try dbo.Table1.
Thomas
"AM" <anonymous@.examnotes.net> wrote in message
news:O5mRGu4SFHA.3176@.TK2MSFTNGP09.phx.gbl...
> Hi all
> What is the impact of adding dbo with tablename
> for example
> select * from dbo. table1
> instead of
> select * from table1
> does adding dbo before table1 makes any benefit?
> Thanks
>
>
>
>|||It improves performance, and for some database objects it is a requirement
(i.e., user-defined functions). It's good to get in the habit of always
qualifying your tables, SP's and UDF's with the owner's name.
"AM" <anonymous@.examnotes.net> wrote in message
news:O5mRGu4SFHA.3176@.TK2MSFTNGP09.phx.gbl...
> Hi all
> What is the impact of adding dbo with tablename
> for example
> select * from dbo. table1
> instead of
> select * from table1
> does adding dbo before table1 makes any benefit?
> Thanks
>
>
>
>|||There is a BIG impact if dbo is not the owner of the table, in which case
SQL Server will not be able to find the table. As others have said, it is
best practices to always qualify an object with the name of its owner. DBO
is a user name in every database, and a frequent owner of objects. But it
is not the only owner of objects.
You can have multiple tables with the same name, so if you say select * from
table1, SQL Server has to figure out WHICH table1 you're referring to. The
default is first to check to see if the current user owns an object table,
and then to check if the user dbo owns a table1.
Please read about users and objects owners in the Books Online.
HTH
--
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"AM" <anonymous@.examnotes.net> wrote in message
news:O5mRGu4SFHA.3176@.TK2MSFTNGP09.phx.gbl...
> Hi all
> What is the impact of adding dbo with tablename
> for example
> select * from dbo. table1
> instead of
> select * from table1
> does adding dbo before table1 makes any benefit?
> Thanks
>
>
>
>

No comments:

Post a Comment