duplicate key value * (asterisk)

  • What does the asterisk mean where it says "duplicate key value is (2, *)"? I'm not inserting an asterisk...

    I put the select by itself to show you the output, and also a select to show there's nothing in that table I'm inserting into... then you see the insert with the same first select gives an error...

    /*------------------------

    select b.QualID, a.PaymentID, a.PaymentDate, a.CustomerID, a.PolID, a.PolicyNumber, a.PolicyType

    from #tempCrossNew a join CrossSellQualified b on b.CSR=a.CSR

    ;

    select * from CrossSellQualifiedDetails

    ;

    insert into CrossSellQualifiedDetails (QualID,PaymentID,Paymentdate,CustomerID,PolID,PolicyNumber,PolicyType)

    select b.QualID, a.PaymentID, a.PaymentDate, a.CustomerID, a.PolID, a.PolicyNumber, a.PolicyType

    from #tempCrossNew a join CrossSellQualified b on b.CSR=a.CSR

    ------------------------*/

    QualID PaymentID PaymentDate CustomerID PolID PolicyNumber PolicyType

    ----------- ----------- ----------------------- ----------- ----------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------

    5 361877 2016-03-17 00:00:00.000 36626 12878 NP6065138 DP3 - Dwelling

    5 372313 2016-03-29 00:00:00.000 114201 12937 NP6067303 Home

    5 391990 2016-04-18 00:00:00.000 67213 13030 ND6012270 DP3 - Dwelling

    5 371273 2016-03-28 00:00:00.000 114135 12929 DF00026533 Home

    5 360911 2016-03-16 00:00:00.000 109205 12681 NP6062038 Home

    5 377683 2016-04-02 00:00:00.000 25058 12809 NP6062262 Home

    5 368212 2016-03-24 00:00:00.000 31133 12356 NP6066379 Home

    5 368211 2016-03-24 00:00:00.000 31133 12356 NP6066379 Home

    5 373201 2016-03-30 00:00:00.000 12135 12941 NP6067449 Home

    5 372904 2016-03-29 00:00:00.000 114232 12945 NP6075891 Home

    (10 row(s) affected)

    QualID PaymentID Paymentdate CustomerID PolID PolicyNumber PolicyType

    ----------- --------- ----------------------- ----------- ----------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------

    (0 row(s) affected)

    Msg 2627, Level 14, State 1, Line 6

    Violation of PRIMARY KEY constraint 'PK_CrossSellQualifiedDetails'. Cannot insert duplicate key in object 'dbo.CrossSellQualifiedDetails'. The duplicate key value is (5, *).

    The statement has been terminated.

    Here's the definition of my CrossSellQualifiedDetails table :

    USE [Daily_Reports]

    GO

    /****** Object: Table [dbo].[CrossSellQualifiedDetails] Script Date: 6/27/2016 5:23:15 PM ******/

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    SET ANSI_PADDING ON

    GO

    CREATE TABLE [dbo].[CrossSellQualifiedDetails](

    [QualID] [int] NOT NULL,

    [PaymentID] [varchar](3) NOT NULL,

    [Paymentdate] [datetime] NULL,

    [CustomerID] [int] NULL,

    [PolID] [int] NULL,

    [PolicyNumber] [nvarchar](255) NULL,

    [PolicyType] [nvarchar](50) NULL,

    CONSTRAINT [PK_CrossSellQualifiedDetails] PRIMARY KEY CLUSTERED

    (

    [QualID] ASC,

    [PaymentID] ASC

    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

    ) ON [PRIMARY]

    GO

    SET ANSI_PADDING OFF

    GO

  • Haha! I just noticed the paymentID column is a varchar(3) for some reason. Changed that to an it, that fixed it.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply