从存储过程中的另一个DB中选择表不起作用

时间:2017-06-23 08:35:43

标签: sql-server stored-procedures

我的查询工作正常。我必须使用另一个数据库中的表进行连接,如下所示:takacs.TecDocB4.dbo

SELECT
TYP_ID as ID,
MFA_ID as ModelID,
concat(DES_TEXTS.TEX_TEXT, ' / ', TYP_KW_FROM)  + 'KW' + ' / ' + DES_TEXTS3.TEX_TEXT as Name    
FROM
takacs.TecDocB4.dbo.TYPES
INNER JOIN MODELS ON MOD_ID = TYP_MOD_ID
INNER JOIN MANUFACTURERS ON MFA_ID = MOD_MFA_ID
INNER JOIN COUNTRY_DESIGNATIONS AS COUNTRY_DESIGNATIONS2 ON COUNTRY_DESIGNATIONS2.CDS_ID = MOD_CDS_ID AND COUNTRY_DESIGNATIONS2.CDS_LNG_ID = 21
INNER JOIN COUNTRY_DESIGNATIONS ON COUNTRY_DESIGNATIONS.CDS_ID = TYP_CDS_ID AND COUNTRY_DESIGNATIONS.CDS_LNG_ID = 21
INNER JOIN DES_TEXTS ON DES_TEXTS.TEX_ID = COUNTRY_DESIGNATIONS.CDS_TEX_ID
 LEFT JOIN DESIGNATIONS ON DESIGNATIONS.DES_ID = TYP_KV_ENGINE_DES_ID AND DESIGNATIONS.DES_LNG_ID = 21
 LEFT JOIN DES_TEXTS AS DES_TEXTS2 ON DES_TEXTS2.TEX_ID = DESIGNATIONS.DES_TEX_ID
 LEFT JOIN DESIGNATIONS AS DESIGNATIONS2 ON DESIGNATIONS2.DES_ID = TYP_KV_FUEL_DES_ID AND DESIGNATIONS2.DES_LNG_ID = 21
 LEFT JOIN DES_TEXTS AS DES_TEXTS3 ON DES_TEXTS3.TEX_ID = DESIGNATIONS2.DES_TEX_ID

WHERE
TYP_MOD_ID = 504;

现在我需要在存储过程中转换此查询,但我不断收到一些错误,如附图所示:

enter image description here

它说有一个未解析的对象takacs.TecDocB4.dbo.TYPES的引用。你能帮帮我吗? 为什么它作为查询工作?并且作为存储过程它不起作用。 提前谢谢!

0 个答案:

没有答案