我在存储过程中使用以下查询。
F_Chem_name
和Language
是输入参数。
是否可以为此查询创建一个视图,并将这些输入参数从存储过程传递给该视图?
如何传递参数以从存储过程中查看?
WITH CTE AS
(
SELECT F_PRODUCT
,n.F_CAS_NUMBER
,c.F_COMPONENT_ID
FROM dbo.PDF_MSDS
CROSS APPLY (SELECT value as F_CAS_NUMBER
FROM STRING_SPLIT(F_CAS_NUMBERS, '¿')
WHERE value <> '') as n
CROSS APPLY (SELECT value as F_COMPONENT_ID
FROM STRING_SPLIT(F_COMPONENT_IDS, '¿')
WHERE value <> '') as c
)
SELECT CTE.F_PRODUCT
,COM.F_Cas_Number
,COM.F_Component_Id
,COM.F_Chem_Name
FROM dbo.Components COM
INNER JOIN CTE
ON CTE.F_CAS_NUMBER = COM.F_Cas_Number
AND CTE.F_COMPONENT_ID = COM.F_Component_Id
WHERE COM.F_Chem_Name LIKE @Chem_Name
AND Language = @Language
答案 0 :(得分:1)