Error Converting Varchar to uniqueidentifier

Posted on 2006-05-23
Medium Priority
Last Modified: 2010-05-18
I am trying to call a stored procedure from Crystal Reports and I'm passing a parameter. I need the parameter to be a uniqueidentifier datatype, but it is being treated as a varchar. Is there a way to convert the varchar to uniqueidentifer before passing it as a parameter? is there maybe another solution to this problem?

Please help
Question by:CochiseCounty
  • 2
  • 2
LVL 21

Accepted Solution

Kevin3NF earned 2000 total points
ID: 16743353
its an implicit conversion...it should convert automatically

Here's a really hacked up code test.  I create two variables...a GUID and a varchar(36) and end up inserting both into a table that has two GUID columns:

declare @MyID uniqueidentifier
Set @MyID = NewID()

Print 'GUID'
Print @MyID

Declare @MyVarCharID varchar(36)
--implicit conversion from guid to varchar right here
Set @MyVarcharID = @MyID

Print 'Varchar'
Print @MyVarcharID

Create table #temp (MyGuid uniqueidentifier, MyVarchar uniqueidentifier)

--this is the varchar to guid conversion,
--since the @MyVarcharID is being inserted to a guid column
Insert #temp
Values (@MyID, @MyVarcharID)

Select *
from #temp

Author Comment

ID: 16744497
I'm not getting any error from in the stored procedure. My problem is that I am calling the stored procedure from Crystal Reports and passing a varchar as a parameter to a uniqueidentifier. I guess I can pass it to a varchar and then do the conversion, but I am in a situation where I need to use the stored procedures that have been in use for quite some time by other applications, in other words, I can't make any changes to the stored procedure, and they don't want me to create any new ones either.

Please help.
LVL 21

Expert Comment

ID: 16744854
Can you profile the actual call to the procedure to verify how it is being passed?  

Author Comment

ID: 16746302
Thank you for your help. I was able to convince the powers that be to let me create a new stored procedure.

By the way, I'm pretty sure the parameter is being passed as a string.

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question