Select based on Variable and IF
declare @t int
declare @location varchar (50)
declare @st varchar (50)
declare @sel nvarchar(1000)
set @t =1
set @location='kolkata'
set @st='lela'
if @t=1
begin
set @sel='SELECT count([UserId]) as TotalDonor FROM [vwUser] where [Location]='''+@location+''''
end
if @t=2
begin
set @sel='SELECT count([UserId]) as TotalDonor FROM [vwUser] where [Street1]='''+@st+''''
end
execute sp_executesql @sel