Sunday, March 25, 2012

Do I need the "dbo" at the end of my stored procedures?

I have some stored procedures with (dbo) after them and some that don't. Do I need this? how do I get rid of it? Do I need to refernence them in my code?

I intend to send my Access 2000 ADP front end to a customer and the back end SQL to them is this naming convention going to cause me issues?

Mitchnormally when one see "dbo" it is at the beginning of a stored proceure name i.e. master.dbo.sp_who.

If you have a database called "db1" and a stored procedure created by dbo called "sp1", you could have your app reference the sp as db1.dbo.sp1 from any db and it should work. From within db1 you could call dbo.sp1 annd that would work too.

If you referrence your sp as "sp1" and user "usr1" has created a stored procedure called "sp1" then when the user, "usr1", executes your sp "sp1" he/she/it will execute db1.usr1.sp1 not db1.dbo.sp1.

IMHO, if you want your users to execute the dbo version of a stored procedures then add "dbo." to the beggining of your sp name.

No comments:

Post a Comment