alter procedure [dbo].[sp_E_GetProducts]
@skip as INT = 0,
@take as INT = 999999,
@search as NVARCHAR(50) = '',
@urtkod as NVARCHAR(50) = ''
as
begin
If (@urtkod is null)
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 + '%'
)
End
Else
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 + '%'
)
End
select * from MyTable where row between @skip and @take
end
Also you can check for ''
....