In microsoft sql server 2005, classic asp code, I call a sql query using this:
selectHireResponseSQL = "
SELECT HireResponseID, HireResponse, DateResponse, Comments, YearFileOpened
, file_number, isCaseOpen, last_update, isConfidential, date_created
, OurClient, TheirClient, ProjectName, DESCRIPTION, lawyer_lastname
, lawyer_firstname, Conflicts.ConflictID
FROM Hire_Response
, Conflicts
, Lawyers
WHERE Hire_Response.ConflictID = Conflicts.ConflictID
AND Lawyers.lawyerID = Conflicts.lawyerID
AND firmID IN (" & FirmIDString & ")
AND HireID = " & HireID & "
AND isStillaConflict = 1
ORDER BY
file_number
, TheirClient
, OurClient
, lawyer_lastname
, lawyer_firstname
"
The above isn't a stored procedure.
Also the FirmIDString variable is a string that is a comma delimited list of numbers, like this for example '1,2,3'.
An example of after the string gets formatted is:
select HireResponseID, HireResponse, DateResponse, Comments, YearFileOpened, file_number, isCaseOpen, last_update, isConfidential, date_created, OurClient, TheirClient, ProjectName, description, lawyer_lastname, lawyer_firstname, Conflicts.ConflictID
from Hire_Response, Conflicts, Lawyers
WHERE Hire_Response.ConflictID=Conflicts.ConflictID AND Lawyers.lawyerID=Conflicts.lawyerID AND firmID IN (47,140,138,137,139) AND HireID = 594 AND isStillaConflict = 1
ORDER BY file_number, TheirClient, OurClient, lawyer_lastname, lawyer_firstname
Now I want to turn this into a stored procedure. So I changed the asp classic code to
selectHireResponseSQL = "
EXEC ps_selectHireResponseSQL '" & FirmIDString & "'," & HireID
And the stored procedure is:
SELECT HireResponseID, HireResponse, DateResponse, Comments, YearFileOpened
, file_number, isCaseOpen, last_update, isConfidential, date_created
, OurClient, TheirClient, ProjectName, DESCRIPTION, lawyer_lastname
, lawyer_firstname, Conflicts.ConflictID
FROM Hire_Response
, Conflicts
, Lawyers
WHERE Hire_Response.ConflictID = Conflicts.ConflictID
AND Lawyers.lawyerID = Conflicts.lawyerID
AND CHARINDEX(',' + CAST(firmID AS NVARCHAR) + ',',','+@FirmIDString + ',') >0
AND HireID = @HireID
AND isStillaConflict = 1
ORDER BY
file_number
, TheirClient
, OurClient
, lawyer_lastname
, lawyer_firstname
But now I am not getting any records at all (the code seems to run without errors though). I know I should be getting records, because if I switch to the non stored procedure, I get records.
Does anyone know what is wrong here?