Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 如何在where子句中添加互不依赖的多个参数_Sql_Sql Server_Reporting Services - Fatal编程技术网

Sql 如何在where子句中添加互不依赖的多个参数

Sql 如何在where子句中添加互不依赖的多个参数,sql,sql-server,reporting-services,Sql,Sql Server,Reporting Services,我需要一个带有5个参数的查询,例如 姓名,姓氏,出生地,出生日期,身份证 该参数的默认值应为null,并且互不依赖。运行报告时,我应该只使用ID等进行筛选。有时我可以使用2个或更多参数进行筛选 Select your columns from some_table where (@name = some_table.name_column or @name is null) and (@surname = some_table.surname_column or @surname is

我需要一个带有5个参数的查询,例如

姓名,姓氏,出生地,出生日期,身份证


该参数的默认值应为null,并且互不依赖。运行报告时,我应该只使用ID等进行筛选。有时我可以使用2个或更多参数进行筛选

Select
your columns

from some_table

where 

(@name = some_table.name_column or @name is null)
and
(@surname = some_table.surname_column or @surname is null)
and
(@birth_place = some_table.birth_place_column or @birth_place is null)
and
(@dateofbirth= some_table.dateofbirth_column or @dateofbirth is null)
and
(@ID= some_table.ID_column or @ID is null)
现在在SSRS中,允许所有参数为空。。当然您需要至少选择一个参数值,否则将有效地返回表中的所有内容。。我相信这是你不想要的。

请参阅ID和voornaam表示未选中名字


我已经尝试过了,但是当我运行报告时,参数@ID没有被选中。我在参数属性中添加了NULL作为默认值。请按SQL中的原样使用上面的代码,看看它是否有效。声明所有参数将除ID之外的所有参数的默认值设置为null,并查看查询是否返回任何内容。嘿,我已经重新构建了报告,并且使用了您的查询。在运行报告时,如果我填充1个参数并查看报告,则在为其他参数输入值时出现错误。您是否已为新报告中的参数?请通过编辑您的问题添加任何注释。。不是通过用更多信息回答您自己的问题嗨,Harry,我已经尝试了您的查询,但例如,如果我在查看报告时在参数名称中键入一个值,它将不会在报告中提供任何数据。问题可能是什么?您能展示一些示例数据和实际查询吗?