Alter procedure spSearchInqoury
@Code Varchar(50),
@ExecutiveName Varchar(50),
@SellingMark Varchar(50),
@OwnerName Varchar(50)
As
select c.CRMCustomerCode As CustomerCode,
ce.ExecutiveName As ExecutiveName,
Estate.SellingMark As SellingMark,
Owner.Name As OwnerName
from CRMCustomer c
inner join CustomerType ct On ct.CustomerTypeID=c.CustomerTypeID
inner join CRMCustomerExecutive ce On ce.CRMCustomerID=c.CRMCustomerID
inner join CustomerEstate cest On cest.CRMCustomerID=c.CRMCustomerID
inner join Estate On Estate.EstateID=cest.EstateID
inner join Owner On Owner.OwnerID=Estate.OwnerID
where
c.CRMCustomerCode like Replace(@Code,’All’,'%%’) OR c.CRMCustomerCode Like ‘%’+@Code+’%’ AND
ce.ExecutiveName like Replace(@ExecutiveName,’All’,'%%’) OR ce.ExecutiveName Like ‘%’+@ExecutiveName+’%’ AND
Estate.SellingMark like Replace(@SellingMark,’All’,'%%’) OR Estate.SellingMark Like ‘%’+@SellingMark+’%’ AND
Owner.Name like Replace(@OwnerName,’All’,'%%’) OR Owner.Name Like ‘%’+@OwnerName+’%’
Logical Operators
= Equal to
!= or
<> Not equal to
> Greater than
>= Greater than or equal to
< Less than
<= Less than or equal to
in Equal to any item in a list
not in Not equal to any item in a list
between Between two values, greater than or equal to one and less than or equal to the other not between
Not between two values
begins with Begins with specified value
contains Contains specified value
not contains Does not contain specified value
is null Is blank
is not null Is not blank
like Like a specified pattern. % means any series of characters. _ means any single character. not like
Not like a specified pattern. % means any series of characters. _ means many single character Department Table DepartmentID DepartmentName 31 Sales 33 Engineeri 34 Clerical 35 Marketing
SELECT Mark, count(*) as Countrows
FROM textreadercheck
GROUP BY Mark
HAVING count(*) > 1