【发布时间】:2021-08-04 20:30:02
【问题描述】:
这是我的 SQL Server 存储过程
CREATE PROC test_sp
@id int,
@ipVal varchar(20) = null,
@browserName varchar(20) = null
as
begin
select * from users where id=@id order by id desc;
end
我想在此动态更改我的where 条件。
@ipVal is not null 时,我应该在 Where 条件下传递所有三个参数。当我的@ipVal is null 时,我应该只在 where 条件下通过id=@id。
如何在 SQL Server 存储过程中做到这一点?
【问题讨论】:
标签: sql sql-server mssql-jdbc