May 22, 2006 at 8:10 am
I inherited support for an application that has a vendor-designed DB that uses GUIDs for virtually every PK. We needed a query for reporting purposes and the vendor built the query and sent it to us. I'm trying to convert the query to an SP so I can reference it from a Crystal Report and I'm having trouble with passing the GUID to the SP. Here's the vendor's query (abbreviated to make it easier):
Select Fullname, Start_Date from tSearch where SearchGUID='BF33FA65-D558-43F5-0F0D20AB0028'
My SP:
When I run the procedure:
@return_value int
'Return Value' = @return_value
I get the following error:
I tried specifying "@srch=[BF33FA65-D558-43F5-0F0D20AB0028]", I tried changing the SP Parm to Varchar and NVarchar. All yielded errors, different errors, but errors.
Is there a standard way to pass a GUID as a parameter in a Stored Procedure? I can't find anything in BOL...
May 22, 2006 at 8:28 am
Is this a real live example?
Select Fullname, Start_Date from tSearch where SearchGUID='BF33FA65-D558-43F5-0F0D20AB0028'
If it is, then the guid is too short to be a guid.
Try with something like 'BF33FA65-D558-43F5-ABD4-0F0D20AB0028' and see if it improves.
(or some other 'real' value - a guid should be 8-4-4-4-12, yours is missing a group of 4)
/Kenneth
May 22, 2006 at 8:38 am
The test GUID should have said 'BF33FA65-D558-43F5-BE47-0F0D20AB0028'.
Turns out my problem was the Select in the SP:
Select Fullname, Start_Date from tSearch where SearchGUID=@srch
I actually had:
Select Fullname, Start_Date from tSearch where SearchGUID='@srch'
Taking off the quotes fixed it.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply