Results 1 to 2 of 2

Thread: List of GUIDS as stored procedure parameter

  1. #1

    Thread Starter
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861

    List of GUIDS as stored procedure parameter

    I'm trying to pass a comma separated list of GUIDs to a stored procedure but keep getting the following error
    Syntax error converting from a character string to uniqueidentifier.
    My stored procedure looks like this
    Code:
    CREATE PROCEDURE stp_GetProductNames
       @ManuID varchar(5000)
    AS
    SELECT DISTINCT A.ProductName
    FROM Products As A
    INNER JOIN Manfacuturers As B On (A.ManufacturerID = B.ManufacturerID)
    WHERE A.ManufacturerID IN (@ManuID) 
    ORDER BY A.ProductName
    The list of GUIDS is the @ManuID parameter.
    The GUIDS just look like this ('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx')

    Anyone know how to get around this error?
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: List of GUIDS as stored procedure parameter

    Heehe.... seems like it should work huh? But it doesn't.... is sees your csv variable as a full string and not a list of items to look in. two ways to handle this, neither of which are very elegant. 1) dynamic SQL .... build it on the fly in the SP, putting the GUIDS where they need to go. 2) And this one is a bit more intense, create a temp table, loop through your parameter, break off each GUID one by one, and put it into the temp table. Then use the temp table in your query.

    Option 2 is how we ened up doing it here.

    Tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width