Synonim为两个数据库 [英] Synonim for two database
问题描述
我有工资单数据库NEW_JAMNAGARPAYROLL。
和另外两个数据库c0012016new_jamnagar和c0012017new_jamnagar。
c0012016new_jamnagar和c0012017new_jamnagar
有桌子LedgerMaster。
i在NEW_JAMNAGARPAYROL中创建了synonim
,LedgerMaster可以在NEW_JAMNAGARPAYRO中使用。
下面是创建我使用的syntex ..
但是这个synonim不能用于c0012017new_jamnaga。
因为我在创建syntex时使用c0012016new_jamnaga
。
如果没有指定db name,synonim会在运行时给出错误..
所以如何创建synonim,以便它适用于两个数据库?
我尝试过:
i have payroll database NEW_JAMNAGARPAYROLL.
and two other database c0012016new_jamnagar and c0012017new_jamnagar.
c0012016new_jamnagar and c0012017new_jamnagar
has table LedgerMaster.
i have create synonim in NEW_JAMNAGARPAYROL
for LedgerMaster to use in NEW_JAMNAGARPAYRO.
Below is create syntex which i have use..
But this synonim will not work for c0012017new_jamnaga.
because i have use c0012016new_jamnaga
in create syntex.
Without specify db name synonim will give error at run time..
so how to create synonim, so that it will work for both database?
What I have tried:
USE [NEW_JAMNAGARPAYROLL]
GO
CREATE SYNONYM [dbo].[LEDGERMASTER] FOR [c0012016new_jamnagar].[DBO].[LEDGERMASTER]
GO
Erorr是:
Erorr is :
Msg 470, Level 16, State 1, Procedure GetPayRollEmployeeByAuto, Line 18
The synonym "LedgerMaster" referenced synonym "LEDGERMASTER". Synonym chaining is not allowed.
推荐答案
同义词LedgerMaster引用同义词LEDGERMASTER。不允许使用同义词链接。
The synonym "LedgerMaster" referenced synonym "LEDGERMASTER". Synonym chaining is not allowed.
基于该错误消息, [c0012016new_jamnagar]。[DBO]。[LEDGERMASTER]
已经同义词。
你不能创建指向另一个同义词的同义词。
你'我需要更改 CREATE SYNONYM
脚本以指向与 [c0012016new_jamnagar]相同的来源。[DBO]。[LEDGERMASTER]
同义词。
Based on that error message, [c0012016new_jamnagar].[DBO].[LEDGERMASTER]
is already a synonym.
You can't create a synonym that points to another synonym.
You'll need to change your CREATE SYNONYM
script to point to the same source as the [c0012016new_jamnagar].[DBO].[LEDGERMASTER]
synonym.
这篇关于Synonim为两个数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!