question

aimyee avatar image
aimyee asked

Synonums or Fully Qualifed in stored procedures best practices questions

Does anyone have any documentation or best practices when you have a database of stored procedures that reference tables from other databases that are on the same server. Would you recomend synonums or fully qualify the database.table name in the stored procedures?

stored-proceduresdatabasetablesbest-practice
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Jeff Moden avatar image
Jeff Moden answered

Let's let you make the decision after I give you some facts in the form of a question...

What would you rather do if they move or rename a database? Repoint several dozen synonyms or find everywhere in all code where you need to change the 3 and 4 part naming when it does eventually happen to you?

Obviously, my recommendation is to ALWAYS use ONLY the two part naming convention for ALL user objects in code. Nothing more and nothing less.

And, yeah... it's pretty easy to write code that will repoint all of your synonyms.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.