문제

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 !

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top