1

我有一个名为“GetLogInfosMsg”的表值函数,我想运行它,并提供来自特定表的一些参数。下面的代码不起作用;我收到消息“当 EXISTS 未引入子查询时,选择列表中只能指定一个表达式。”。有人可以帮助我吗?谢谢。

SELECT
    @pErrMsgID = [MsgID], 
    @pParams = [Params]
FROM 
    [dbo].[GetLogInfoMsg]((SELECT 
                               [FIELD1],
                               [FIELD2],
                               [FIELD3]
                           FROM [dbo].[TABLE1]
                           WHERE [TABLE1].[UUID] = @pUUID));
4

2 回答 2

1

试试这个

你必须单独传递参数而不是表格格式

SELECT  @pErrMsgID = [MsgID] ,
        @pParams = [Params]
FROM    [dbo].[GetLogInfoMsg](( SELECT  [FIELD1]
                                FROM    [dbo].[TABLE1]
                                WHERE   [TABLE1].[UUID] = @pUUID
                              ), ( SELECT   [FIELD2]
                                   FROM     [dbo].[TABLE1]
                                   WHERE    [TABLE1].[UUID] = @pUUID
                                 ), ( SELECT    [FIELD3]
                                      FROM      [dbo].[TABLE1]
                                      WHERE     [TABLE1].[UUID] = @pUUID
                                    )) ;
于 2013-07-01T09:34:06.133 回答
0

如果您使用的是 mssql 2005+,请考虑使用:

SELECT
    @pErrMsgID = t2.[MsgID], 
    @pParams   = t2.[Params]
FROM [dbo].[TABLE1] t1
CROSS APPLY (SELECT [MsgID], [Params] 
FROM [dbo].[GetLogInfoMsg] (t1.FIELD1, t1.FIELD2, t1.FIELD3) t2
WHERE t1.[UUID] = @pUUID
于 2013-07-01T11:45:11.407 回答