Error Converting Varchar to uniqueidentifier

Posted on 2006-05-23
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
    LVL 21

    Accepted Solution

    its an implicit 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

    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

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

    Author Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Introduction If you are not already aware of what you could use a table with sequential integer values for in SQL, you can read Delimited String Parsing in SQL Server 2005 or later ( by BrandonGalderisi (h…
    APEX (Application Express) is used to develop a web application from Oracle. SQL Workshop is one of the tools that comes with Oracle APEX to query or modify the database objects or to make any changes to the structure.
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now