Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
676 B
6
Indexable
Never
declare @BaslangicTarihi datetime
declare @BitisTarihi datetime
declare @FirmaId uniqueidentifier

set @BaslangicTarihi='2015-01-23'
set @BitisTarihi='2016-08-24'
set @FirmaId='121CBFD9-828B-44F8-99FE-41B6E6C6D235'

select
fc.FirmId,
fc.FoodRegistryStartDate as Baslangic,
fc.FoodRegistryEndDate as Bitis
from usks.FirmCodes as fc with(nolock)
inner join usks.SupplyContract as sc with(nolock) on fc.FirmId=sc.FirmId
where 
fc.Deleted=0 and sc.Deleted=0 and
(fc.FirmId=@FirmaId) and
(@BaslangicTarihi between fc.FoodRegistryStartDate and fc.FoodRegistryEndDate) and
(fc.FoodRegistryEndDate is null or
(@BitisTarihi between fc.FoodRegistryStartDate and fc.FoodRegistryEndDate))