2
我想轉換一個過程以在SQL Azure中使用。我首先在OPENXML
上遇到錯誤,說它在SQL Azure上不受支持,然後我發現它可以替換爲nodes
。我不知道如何轉換WITH (Id BIGINT '.')
部分。我知道WITH
創建了子查詢,但'.'
在這裏做什麼?如何轉換處理OPENXML,WITH和BIGINT的T-SQL?
CREATE Procedure [dbo].[DocsR]
@ids xml -- <Ids><Id>1</Id><Id>2</Id></Ids>
AS
BEGIN
SET NOCOUNT ON;
DECLARE @IdsXml xml
exec sp_xml_preparedocument @IdsXml OUTPUT, @Ids
SELECT
DoctId,
DocNm
FROM
Docs
WHERE
--DocId IN (SELECT Id FROM OPENXML(@IdsXml, '/Ids/Id', 2) WITH (Id BIGINT '.'))
DocId IN (SELECT Id FROM @IdsXml.nodes('/Ids/Id') WITH (Id BIGINT '.'))
END
GO
錯誤:
Incorrect syntax near the keyword 'with'. If this statement is a common
table expression, an xmlnamespaces clause or a change tracking context clause,
the previous statement must be terminated with a semicolon.
''是一個引用當前節點值的XPath表達式。基本上,您的查詢將所有/ Ids/Id的值選擇爲「Id」列。 – Mihai