Link to home
Create AccountLog in
Avatar of HADDADD3
HADDADD3

asked on

Stored Procedure Returning Wrong Result

See the SP below.

The table column has the value

"b3148336-3c1b-44ed-a059-14dbb3.tif" stored in it. The stored procedure should return that value.

The stored procedure is actually returning "b3148336-3c1b-44ed-a059-14dbb3"

Why is it trunkating the .tif from the return value? It is cast in the DB as a varchar(40)

What else should i check/test? If i just run the query in query analyzer it works fine
select image_file from patient_images where person_ID=(pid)

that returns the correct result. Im wondering if its a cast issue, any thoughts?
SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO
 
 
 
ALTER       Procedure lei_get_last_test_image
    (
        @pid varchar(50),
	@imagetype varchar(50),
	@imagename nvarchar(40) OUTPUT
 
)
As
select @imagename=image_file
 
 
from patient_images
 
 
where person_id=@pid
AND image_desc LIKE @imagetype
 
 
 
 
 
 
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of UnifiedIS
UnifiedIS

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
I would change the nvarchar(40  to Varchar(40) for starters

SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Just a trivial question, the field image_file has the full image name with the extension? Or could be another field with that information.

As THBA said, what happens if you executes for example:
SELECT * -- try with * to see if there are a different field with that information
FROM patient_images
WHERE person_id=  *** put the id here
AND image_desc LIKE *** put the desc here

Is the "image_file" information complete or there are any other field?