开发者

Error when creating Synonym in SQL Server 2005 with the same table name

开发者 https://www.devze.com 2023-02-16 18:44 出处:网络
I want to create Synonym for a table , so all the other users in this database use this Synonyminstead of writingdata开发者_高级运维basename.schema.table , but when I write :

I want to create Synonym for a table , so all the other users in this database use this Synonym instead of writing data开发者_高级运维basename.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

0

精彩评论

暂无评论...
验证码 换一张
取 消