I am making a procedure for usersearch that has the following parameter:
@BusinessName nvarchar(200) = null,
@BusinessDescription nvarchar(250) =null
create procedure [dbo].[UserSearch]
(
@BusinessName nvarchar(200) = null,
@BusinessDescription nvarchar(250) =null
)
as
if(@BusinessName is not null and @BusinessDescription is null)
begin
select BusinessName,BusinessLikes,BusinessUrl,BusinessAddress2,CountryName, UserId, BusinessCity,BusinessAddress1,StateName,BusinessCreationDate,BusinessTotalReviews,BusinessRatingValue,BusinessKeywords,
case when BusinessLogo is null or BusinessLogo = '' then 'default.gif'
else BusinessLogo end as BusinessLogo,BusinessCategories,substring(BusinessBriefDescription,1,60) as BusinessBriefDescription,BusinessId,BusinessPostalCode
from tblBusinesses where BusinessStatus =1 and (BusinessName Like @BusinessName + '%')
end
Now I need:
(if @businessdescription is not null and @businessname is null)
The problem is that I can use this condition but for this I have to use again the avobe select query. I only need to change in where condition. Can I use my next condition in where clause? If yes than how?