Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Synonym Limitation Questions
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Yak Posting Veteran

76 Posts

Posted - 09/20/2013 :  16:46:25  Show Profile  Reply with Quote
Good afternoon.

I have come across and interesting issue with regards to the user of synonyms and was curious if anyone has knowledge of this.

I essentially have a database that has logging functions and stored procedures. Within a second database I have created sysnonyms so that I do not need to reference the three part name in my procedure. Example follows.

ETL Database
LogMessage (stored procedure)
GetEvent (function) get event associated to the message to log

BASE Database
LogMessage = Synonym of Etl.dbo.LogMessage
GetEvent = Synonym of Etl.dbo.GetEvent

The issue I am having is that after a third level of sub-procedures the LogMessage store procedure fails with the following message.
Report.Post_Report: At line 259: Report.[Post_Report_Sub1] : At line 92: Report.[Get_Sub2] : At line 1: Database 'ETL' does not exist. Make sure that the name is entered correctly.

However, the GetEvent function will still work at the last level just not the LogMessage procedure.

Curious if anyone else has seen this behaivour. Thanks.

Bustaz Kool
Flowing Fount of Yak Knowledge

1834 Posts

Posted - 09/23/2013 :  19:43:50  Show Profile  Reply with Quote
Are any of the intervening stored procedures being run in a different security context? This could be via an "EXECUTE AS" clause at create time or run time.

The cure for anything is salt water -- sweat, tears, or the sea. -Isak Dinesen
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000