Link to home
Start Free TrialLog in
Avatar of indy500fan
indy500fan

asked on

When running a stored procedure with a parameter, why does 4T give me the same result as 4?

My stored proc worked great when CarNumber was an integer, but I found out that the data may be more than just a number.  It could include letters too!  

Here is the stored proc:

CREATE PROCEDURE dbo.GetDriverInfoSP
@CarNumber as varchar
AS
SELECT
CarNumber,
LastName=rtrim(LastName),
FirstName=rtrim(FirstName),
Equipment,
Engine
FROM
Qualifications
WHERE CarNumber = @CarNumber
GO

CarNumber    LastName     FirstName    Equiptment   Engine
4                | Madison     | Davey       | Prototype 1 | Chevy
4T              | Clark          | Mike         | Prototype 2 | BMW

Datatypes

CarNumber = varchar
LastName = varchar
FirstName  = varchar  
Equiptment = varchar  
Engine = varchar

The following Line in Query Analyser:

GetDriverInfoSP '4T'

gives me the same results that the following line gives me:

GetDriverInfoSP '4'

What gives?
ASKER CERTIFIED SOLUTION
Avatar of rafrancisco
rafrancisco

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rafrancisco
rafrancisco

This is why you get the same result for '4T' and '4'.  Your query is just comparing it against '4'.
Avatar of indy500fan

ASKER

Yep!  That worked.  I wish I had thought of that!!!  Thanks for the extra fast response time!!!
You're welcome.  Glad I was able to help.  Have a good day.