我正在尝试一个 sql 查询
alter procedure [dbo].[sp_E_GetProducts]
@skip as INT = 0,
@take as INT = 999999,
@search as NVARCHAR(50) = '',
@urtkod as NVARCHAR(50) = ''
as
begin
; with MyTable as (
select sto_kod, sto_isim, sto_sat_cari_kod, ROW_NUMBER() OVER (ORDER BY sto_kod) as row from MikroDB_V14_AKCAY2010.dbo.STOKLAR where
(sto_isim like '%' + @search + '%' or sto_kod like '%' + @search + '%') and sto_sat_cari_kod <> '' and @urtkod like '%' + sto_sat_cari_kod + '%'
)
select * from MyTable where row between @skip and @take
end
当我将参数设置为非空但当@urtkod 为空时,它的工作原理我想获取所有表(这意味着“和 sto_sat_cari_kod <> '' 和 @urtkod 像 '%' + sto_sat_cari_kod + '%'”将忽略),我研究“情况下”,但它没有用,或者我做错了。