我有这个 SQL 语句,但我有错误必须声明标量变量“@InputPath”
IF OBJECT_ID('DBO.SP_INSERT_REQUESTS') IS NULL BEGIN
EXEC('CREATE PROCEDURE DBO.SP_INSERT_REQUESTS AS RETURN')
GRANT EXECUTE ON DBO.SP_INSERT_REQUESTS TO PUBLIC
END
GO
ALTER PROCEDURE DBO.SP_INSERT_REQUESTS
@Name NVARCHAR(512),
@Code NVARCHAR(50),
@InputPath NVARCHAR(2000),
@OutputPath NVARCHAR(2000)
AS
GO
SET QUOTED_IDENTIFIER OFF
--DECLARE @InputPath varchar(2000) = "c:\MyDoc1.xsd"
DECLARE @InputValue XML
--DECLARE @OutputPath varchar(2000) = "c:\MyDoc2.xsd"
DECLARE @OutputValue XML
DECLARE @QUERY NVARCHAR(4000) SET @QUERY = "
SELECT @InputValue = InputExample.BulkColumn
FROM OPENROWSET (BULK '"+@InputPath+"', SINGLE_BLOB) AS InputExample;
SELECT @OutputValue = InputExample.BulkColumn
FROM OPENROWSET (BULK '"+@OutputPath+"', SINGLE_BLOB) AS InputExample;
"
EXEC SP_EXECUTESQL @QUERY, N'@InputValue XML out, @OutputValue XML out', @InputValue out, @OutputValue out
INSERT INTO MyTable(Name, Code, Input, Output)
VALUES('value1', 'value2' , @InputValue, @OutputValue)
我已经声明了参数,所以我不明白为什么会出现错误。