March 27, 2012 at 12:03 pm
SS999 (3/27/2012)
Currently its on sql server 2005.
You posted in a SQL Server 2008 forum, that usually means you will get SQL Server 2008 answers that don't necessarily work in SQL Server 2005.
We make assumptions based on where a post is made.
March 27, 2012 at 12:10 pm
I will make sure to post in a right way next time. Apologies!!!
March 27, 2012 at 12:12 pm
SS999 (3/27/2012)
I will make sure to post in a right way next time. Apologies!!!
None needed. Now that we know we are dealing with SQL Server 2005, we just make some adjustments to what we suggest.
March 27, 2012 at 12:27 pm
When i run the original sp i m getting 616rows, but whem i m running the sp given by elutin, i m getting only 242 rows.
March 28, 2012 at 2:20 am
You had missing brackets (and wildcard %) in your WHERE clause - in place where you check for FirstName or LastName:
...
WHERE dpr.AgentID = @TempVQAgentID AND dpr.StateID = @TempVQStateID
AND (((@TempVQAppFName <> '' AND @TempVQAppFName IS NOT NULL AND @TempVQAppLName <> '' AND @TempVQAppLName IS NOT NULL)
AND dpr.InsuredName1 LIKE '%' + @TempVQAppFName + ' ' + @TempVQAppLName + '%' OR dpr.InsuredName2 LIKE '%' + @TempVQAppFName + ' ' + @TempVQAppLName)
...
Hard to see where? It's extremely helpful to format and indent T-SQL code...
Your current condition would select everything where
"InsuredName2 LIKE '%' + @TempVQAppFName + ' ' + @TempVQAppLName", It should be in brackets together with check of dpr.InsuredName1...
As you can guess, I cannot run and check the code I've written. As I don't have your database.
Viewing 5 posts - 31 through 34 (of 34 total)
You must be logged in to reply to this topic. Login to reply