It sounds like you are encountering an issue with using synonyms for scalar value functions in SQL Server. According to the documentation, while you can create synonyms for various database objects, including scalar value functions, there are some important considerations to keep in mind:
- Schema Binding: Synonyms are not schema-bound, meaning they do not enforce the existence of the underlying object until runtime. If the function was modified or dropped after the synonym was created, it could lead to the ambiguity or "not found" errors you are experiencing.
- Ambiguity: The error message indicating that the name cannot be found or is ambiguous might suggest that there are multiple objects with similar names in the context of the database. Ensure that there are no naming conflicts or that the correct schema is being referenced.
- Permissions: Ensure that the user context under which the call is made has the necessary permissions to execute the function through the synonym.
- Linked Servers: If the synonym references a function on a linked server, it cannot be used directly, which may also lead to issues.
Since you mentioned that the script used to drop and recreate synonyms did not include the scalar function synonym, it’s possible that the function was inadvertently affected by changes in the database or that the synonym was not properly pointing to the correct object.
If the issue persists, it may be worth checking for any updates or patches for SQL Server that might address this behavior, as well as reviewing any changes made to the function or its dependencies.
References: