代码改变世界

SQL,不定条件查询,case,when,then,end,isnull,join,inner,on

  Virus-BeautyCode  阅读(1563)  评论(0编辑  收藏  举报

复制代码
create procedure SelectProduceInfo
@Ope varchar(50),
@ProBeginDate datetime,
@ProEndDate datetime,
@IP varchar(50),
@ComputerName varchar(50),
@ProType varchar(50),
@DiskType varchar(50),
@KBID varchar(50),
@CustName varchar(50),
@CfgID int,
@ProBatch varchar(50)
as
select Operator as '操作员',ProduceDate as '生产日期',IPAddress as 'IP地址',ComputerName as '计算机名',
'产品类型'=case ProductType when '1' then 'Key' when '2' then 'U盘' when '3' then 'U盘/Key' end,
'U盘类型'=case UdiskType when '0' then '单机版安全U盘' when '1' then '企业版安全U盘' when '2' then '企业版管理盘' end,
KBUdiskID 
as 'U盘金邦ID',CustomerName as '客户',CfgName as '配置',
ProduceBatch 
as '生产批次号',ProduceRemark as '生产备注' from ProduceUdiskKeyInfo a inner join UdiskPolicyConfigInfo b
on a.ConfigAutoID=b.ConfigAutoID
where Operator=isnull(@Ope,Operator) and ProduceDate>=isnull(@ProBeginDate,ProduceDate) 
and ProduceDate<=isnull(@ProEndDate,ProduceDate) and IPAddress=isnull(@IP,IPAddress)
and ComputerName=isnull(@ComputerName,ComputerName) and ProductType=isnull(@ProType,ProductType)
and UdiskType=isnull(@DiskType,UdiskType) and KBUdiskID=isnull(@KBID,KBUdiskID)
and CustomerName=isnull(@CustName,CustomerName) and a.ConfigAutoID=isnull(@CfgID,a.ConfigAutoID)
and ProduceBatch=isnull(@ProBatch,ProduceBatch)
go
复制代码

编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示