Hello Everyone,
I have a table with the below fields
CategoryId (int)
Code (varchar)
City (varchar)
State (varchar)
Zip (varchar)
DocumnetText (text)
I am developing a web application, where user can search on any combination of the fileds. DocumnetText is searched on keywords.
Where condition in my stored procedure looks some thing like this
WHERE
((@CategoryId is Null) or (CategoryId = @CategoryId ))
AND
((@Code is Null) or (Code = @Code ))
AND
((@City is Null) or (City = @City ))
AND
((@State is Null) or (State = @State ))
AND
((@Zip is Null) or (Zip = @Zip ))
AND
((@Keyword is Null) or (CONTAINS(DocumnetText ,@Keyword ))
The performance of the above query is not upto the expectations.
Can some one shed light on the best practices to write a query in such cases?
Thanks for your help in advance
I have a table with the below fields
CategoryId (int)
Code (varchar)
City (varchar)
State (varchar)
Zip (varchar)
DocumnetText (text)
I am developing a web application, where user can search on any combination of the fileds. DocumnetText is searched on keywords.
Where condition in my stored procedure looks some thing like this
WHERE
((@CategoryId is Null) or (CategoryId = @CategoryId ))
AND
((@Code is Null) or (Code = @Code ))
AND
((@City is Null) or (City = @City ))
AND
((@State is Null) or (State = @State ))
AND
((@Zip is Null) or (Zip = @Zip ))
AND
((@Keyword is Null) or (CONTAINS(DocumnetText ,@Keyword ))
The performance of the above query is not upto the expectations.
Can some one shed light on the best practices to write a query in such cases?
Thanks for your help in advance