如何解决以下问题 [英] How to solve following problem
本文介绍了如何解决以下问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
declare @vc_supplier_name varchar(200) =''
declare @in_supplier_type_id int =2
declare @bt_active bit
SELECT a.in_supplier_id, dbo.format_fnc_bit(1, a.bt_active) AS vc_active, b.vc_supplier_type_name, a.in_supplier_type_id, a.vc_supplier_name,
dbo.admin_user_fnc_get_name(1, a.in_updatedby_user_id) AS vc_updated_by, a.dt_updated
FROM dbo.supplier a
INNER JOIN dbo.common_data_vw_supplier_type b ON a.in_supplier_type_id = b.in_supplier_type_id
WHERE a.in_supplier_type_id = @in_supplier_type_id AND a.vc_supplier_name LIKE '%' + @vc_supplier_name + '%'
AND if(@bt_active <> '') a.bt_active= @bt_active
ORDER BY a.vc_supplier_name
这里我从aps.net页面传递bt_active ..所以我想检查一下如果bt_active传递为1那么它应该用Active Record过滤掉其他所有记录都应显示
Here I pass bt_active from aps.net page .. So i want to check that if bt_active is passes as 1 then it should filter with Active record else all record should display
推荐答案
最简单的方法是:
The simplest approach is this:
AND (@bt_active = 0 OR a.bt_active=1)
如果@bt_active
变量和a.bt_active
字段只能存储0
和1
,当0表示非活动时并且1表示活动,您需要构建查询取决于此变量:
If@bt_active
variable anda.bt_active
field can stores only0
and1
, when 0 means non-active and 1 means active, you need to build query depends on this variable:
IF @bt_active = 1
BEGIN
--query to get active records
ELSE
--query to get all records
END
这篇关于如何解决以下问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文