Description
Hello,
I noticed that when the value of the parameter of tested procedure is equal to the sql keyword - procedure tSQLt.ResultSetFilter returns an error:
System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'AS'.
Test script:
USE tSQLt_Example
GOIF OBJECT_ID('dbo.uspForTest') IS NOT NULL
DROP PROCEDURE dbo.uspForTest
GOCREATE PROCEDURE dbo.uspForTest
(
@InParam01 VARCHAR(20)
)
AS
BEGIN
SELECT @InParam01 [InParam01]
ENd
GOIF OBJECT_ID('dbo.test_uspForTest') IS NOT NULL
DROP PROCEDURE dbo.test_uspForTest
GO-- ok test case
CREATE PROCEDURE dbo.test_uspForTest
AS
BEGINCREATE TABLE #uspForTest
(
InParam01 VARCHAR(20)
)DECLARE @command VARCHAR(4000)
DECLARE @InParam01 VARCHAR(20)SET @InParam01 = 'AT'
SET @command = 'EXEC dbo.uspForTest @InParam01 = ' + @InParam01
INSERT INTO #uspForTest
EXEC tSQLt.ResultSetFilter
@ResultsetNo = 1
, @command = @commandSELECT * FROM #uspForTest
END
GOEXEC tSQLt.Run '[dbo].[test_uspForTest]'
GO-- error test case
ALTER PROCEDURE dbo.test_uspForTest
AS
BEGINCREATE TABLE #uspForTest
(
InParam01 VARCHAR(20)
)DECLARE @command VARCHAR(4000)
DECLARE @InParam01 VARCHAR(20)SET @InParam01 = 'AS'
SET @command = 'EXEC dbo.uspForTest @InParam01 = ' + @InParam01
INSERT INTO #uspForTest
EXEC tSQLt.ResultSetFilter
@ResultsetNo = 1
, @command = @commandSELECT * FROM #uspForTest
END
GOEXEC tSQLt.Run '[dbo].[test_uspForTest]'
GO