将伪参数传递给SQL查询

时间:2022-05-21 04:35:45

I am new to sql query and got stuck in middle of some query.

我是sql查询的新手,陷入了一些查询的中间。

Issue:- my query where condition is like this "where new_FleetSeries in (@fleet)" now in report everything is working fine. But i want to make this query run in SQL for testing and in order to test i have created on variable and manually filled the values something like below.

问题: - 我的查询条件是这样的“其中new_FleetSeries in(@fleet)”现在在报告中一切正常。但是我想让这个查询在SQL中运行以进行测试,并且为了测试我在变量上创建并手动填充下面的值。

Declare @fleet varchar(150) SET @fleet= ('B777,B777F-200, B777F-200L')

Now if i select the same parameters from report my report gives me result but same parameters if i fill manually didnt gives me result in SQL.

现在,如果我从报告中选择相同的参数,我的报告给出结果,但如果我手动填充相同的参数didnt给我结果SQL。

1 个解决方案

#1


0  

The IN clause must have values not only one string something like this

IN子句必须具有不仅仅是一个字符串的值

where new_FleetSeries in ('B777','B777F-200', 'B777F-200L')

so instead of filling a parameter , you have to concatenate those values to the original query

因此,您必须将这些值连接到原始查询,而不是填充参数

#1


0  

The IN clause must have values not only one string something like this

IN子句必须具有不仅仅是一个字符串的值

where new_FleetSeries in ('B777','B777F-200', 'B777F-200L')

so instead of filling a parameter , you have to concatenate those values to the original query

因此,您必须将这些值连接到原始查询,而不是填充参数