У меня есть сохраненная pro c, которая присоединяется к нескольким различным таблицам. Я пытаюсь отфильтровать возвращаемое значение, добавляя новый параметр с именем @CodeId int
. CodeId
- это столбец в таблице, которую я использую, с именем tblInformation
Я пытаюсь выбрать из этой таблицы, где tblCodeId = @CodeId
при этом я получаю сообщение об ошибке:
выражение не-логического типа с указанием c в контексте, где ожидается условие
Я неправильно включил свой оператор Where
?
Я ожидаю включить в свой запрос условие where, чтобы вернуть отфильтрованные данные с целым числом параметра, которое я включаю для CodeId
Вот мой запрос:
@CountryId int
, @AreaID int
, @CodeId int -- My new parameter
AS
BEGIN
select
i.IdCountry,
i.IdArea,
i.IdIndustry,
i.tblCodeId,
i.DsIndustry,
from dbo.tblInformation i
where tblCodeId= @CodeId -- Where I am attempting to add where condition
inner join dbo.tblInformationAnalysis ia
on ia.IdCountry = i.IdCountry
and ia.IdArea = i.IdArea
and ia.IdIndustry = i.IdIndustry
and ia.idindustryanalysis = 1
inner join (
select
IdCountry,
IdArea,
IdIndustry,
idindustryanalysis
from dbo.tblInformationAnalysis
where IdCountry = @CountryID
and IdArea = @AreaID
and idindustryanalysis = 1
group by IdCountry,
IdArea,
IdIndustry,
idindustryanalysis
) via
on via.idcountry = ia.idcountry
and via.idarea = ia.idarea
and via.IdIndustry = ia.IdIndustry
and via.idindustryanalysis = ia.idindustryanalysis
inner join dbo.tblRetailData r
on r.IdCountry = i.IdCountry
and r.IdArea = i.IdArea
and r.IdIndustry = i.IdIndustry
inner join dbo.tblCounty c
on c.IdCountry = r.IdCountry
and c.IdArea = r.IdArea
and c.CurrentYr = 1
and c.YrRisk = r.YrRisk
inner join dbo.tblRetailDataPublished rp
on rp.IdCountry = i.IdCountry
and rp.IDArea = i.IdArea
and rp.EntityID = i.IdIndustry
and rp.ReportTypeID = 1
inner join dbo.RetailCollection rc
on rc.IdCountry = i.IdCountry
and rc.IdArea = i.IdArea
where i.IdCountry = @CountryID
and i.IdArea = @AreaID
and i.IdLanguage_PK = @Language_PK
END