我想创建一个以表值函数为列的存储过程。我想使用其他列值之一作为函数的参数。
ALTER PROCEDURE [dbo].[AuditReportLeaseID]
@leaseID int
AS
BEGIN
SET NOCOUNT ON;
SELECT
a.assetID as Asset, a.Location,
CONVERT(VARCHAR, a.auditdate, 101) AS Date,
a.qtyaudit AS Qty,
c.classname AS Class, a.grade AS Grade,
a.serialnumber AS [S/N],
a.materialdescription AS Description, a.Notes,
(SELECT tf.AD
FROM fGetAuditDescrConcat(a.assetId) tf) AS AuditDescription
FROM
audit a
LEFT OUTER JOIN
ORDER_DETAILS od ON a.assetID = od.assetId
INNER JOIN
class c ON a.classid = c.classid
WHERE
a.classID = c.classID
AND a.leaseID = @leaseID
ORDER BY
class, grade, a.materialDescription
END
此过程将返回多行,我想使用第一列a.assetID
(即 a varchar(64)
)的值作为fGetAuditDescrConcat
函数的参数。
这可能吗?