[英]SQL SERVER exec Stored Procedure to CASE WHEN condition
I have a query that select some table from another server (with IP LINK), it's okay with table select. 我有一个查询,该查询从另一台服务器(具有IP LINK)中选择一些表,可以选择表。 But when I put a FUNCTION (Store procedure) into CASE WHEN condition, it doesnt work..
但是,当我将FUNCTION(存储过程)放入CASE WHEN条件时,它不起作用。
SELECT
CASE
WHEN A.TGL IS NULL THEN
B.TGL
ELSE
[123.123.111].[DBNAME].dbo.Func_S(A.NOREK, B.NAMA, A.TGL)
END AS TGL_ANSURAN
FROM
[123.123.111].[DBNAME].dbo.TblName AS A
JOIN [123.123.111].[DBNAME].dbo.TblName2 B ON A.ID = B.ID
when I execute that, error message shows : 当我执行该操作时,错误消息显示:
"[Err] 42000 - [SQL Server]Remote function reference '[123.123.111].[DBNAME].dbo.Func_S' is not allowed, and the column name '123.123.111' could not be found or is ambiguous."
“ [Err] 42000-[SQL Server]远程函数引用'[123.123.111]。[DBNAME] .dbo.Func_S'不允许,并且列名'123.123.111'找不到或不明确。”
What's wrong with my query? 我的查询出了什么问题? the
Func_S
is exist and my server has already linked with network server. Func_S
存在,并且我的服务器已经与网络服务器链接。
You should use openquery to select functions - So try if this should work. 您应该使用openquery来选择函数-因此请尝试这样做是否可行。
select
a.*
from
OPENQUERY ( [123.123.111],
'
SELECT
CASE
WHEN A.TGL IS NULL THEN
B.TGL
ELSE
[DBNAME].dbo.Func_S(A.NOREK, B.NAMA, A.TGL)
END AS TGL_ANSURAN
FROM
[DBNAME].dbo.TblName AS A
JOIN [DBNAME].dbo.TblName2 B ON A.ID = B.ID
' ) a
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.