Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
mk_garg20
Constraint Violating Yak Guru
343 Posts |
Posted - 2005-06-16 : 03:03:35
|
| what is difference between following 2 statements when written in a stored procedure.select employeeid, name from employeeselect employeeid, name from dbo.employeeWill there be any performance difference between these two.Thanksmk_garg |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-06-16 : 03:30:37
|
| dbo is the owner of the tablePerformance is sameMadhivananFailing to plan is Planning to fail |
 |
|
|
mk_garg20
Constraint Violating Yak Guru
343 Posts |
Posted - 2005-06-16 : 03:34:37
|
| Then why sometime people use dbo.Tablename in stored procedures.mk_garg |
 |
|
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
Posted - 2005-06-16 : 05:20:19
|
| that is really a best practice. SQL Server is a little different than other databases in that it assumes you meant to specify dbo.* when you said SELECT * FROM TABLENAME. Being precise like that is a good habit to get into.-ec |
 |
|
|
mk_garg20
Constraint Violating Yak Guru
343 Posts |
Posted - 2005-06-16 : 06:28:11
|
| Thanks !mk_garg |
 |
|
|
amitja
Starting Member
7 Posts |
Posted - 2005-06-16 : 06:43:35
|
| Using dbo.[tablename] also ensures that your application never fails. Consider this scenario.You create a login "testuser" and grant select permissions on this table and connect to SQL server using this login.The statement "Select * from [Tablename]" will return you an error "Object does not exist" as it would assume an object testuser.[Tablename] which SQL Server wont find. Specifying dbo.[Tablename] will return u the desired results instead.Amit |
 |
|
|
mk_garg20
Constraint Violating Yak Guru
343 Posts |
Posted - 2005-06-16 : 18:07:36
|
| Thanks again Amit!mk_garg |
 |
|
|
|
|
|