Question

I want to create Synonym for a table , so all the other users in this database use this Synonym instead of writing databasename.schema.table , but when I write :

CREATE SYNONYM [ACCT_STMT] FOR [AccountStatementPRD].[dbo].[ACCT_STMT]
GO

it generates an error msg :

There is already an object named 'ACCT_STMT' in the database. Msg 4606,

in oracle , I can create Synonym with the same table name !

Was it helpful?

Solution

if all you want is to use it by name only, and you already executing the statment in the correct DB, you don't have to use databasename.schema.tablename, just use tablename

for example, instead of

SELECT * FROM [AccountStatementPRD].[dbo].[ACCT_STMT]

you can just do

SELECT * FROM [ACCT_STMT]

as far as having the same name for synonym, that will not work in the same DB

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top