I am creating a stored procedure that will be called from one database but needs to access tables in other databases. We have a different database for each of our clients. I'm trying to create a synonym dynamically based on parameters:
DECLARE @SQL varchar(150)
SET @SQL = 'CREATE SYNONYM synATClaimMatched FOR ' + ... <params> ...
EXEC @SQL
But this results in the following error:
Msg 2812, Level 16, State 62, Line 3
Could not find stored procedure ''.".
Does anybody know why I'm getting this error and how to fix it?