Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

'Operand type clash: numeric is incompatible with uniqueiden

Tags:
  1. Feb 3, 2016 #1
    Could use some help figuring out the error

    Operand type clash: numeric is incompatible with uniqueidentifier

    which points to the specified line below

    Code (Text):

    CREATE PROCEDURE AddPartner
        @name NVARCHAR(50), @email NVARCHAR(254), @new_guid UNIQUEIDENTIFIER OUTPUT
    AS
    BEGIN
        SET NOCOUNT ON
        INSERT INTO Partners (name,email) VALUES (@name,@email)
        SELECT @new_guid = SCOPE_IDENTITY() -- specified line
        RETURN
    END  
     
    The table Partners is of the form

    Code (Text):

    CREATE TABLE Partners (
        id UNIQUEIDENTIFIER NOT NULL DEFAULT NEWID(),
        name NVARCHAR(50) NOT NULL,
        email NVARCHAR(254) NOT NULL, -- 254 is optimal length according to http://stackoverflow.com/questions/1199190/what-is-the-optimal-length-for-an-email-address-in-a-database
        PRIMARY KEY (id)
    );
     
    Any help in figuring out this error? What I'm trying to do is return from the procedure the guid that was just assigned to the row that was just inserted.
     
  2. jcsd
  3. Feb 3, 2016 #2

    Samy_A

    User Avatar
    Science Advisor
    Homework Helper

    SCOPE_IDENTITY() doesn't work with guid fields.

    Here they show how you could get the last inserted guid (haven't tested it).
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: 'Operand type clash: numeric is incompatible with uniqueiden
  1. Numerical methods (Replies: 1)

  2. Numerical analysis (Replies: 1)

Loading...