Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6547847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:52:51+00:00 2026-05-25T11:52:51+00:00

I have this constraint in a table: CREATE TABLE [dbo].[InventoryLocations] ( [recid] [int] IDENTITY(1,1)

  • 0

I have this constraint in a table:

CREATE TABLE [dbo].[InventoryLocations]
(
    [recid] [int] IDENTITY(1,1) NOT NULL,
    [LocItemNumber] [char](16) NOT NULL,
    [WareHouse] [char](2) NOT NULL,
    [Aisle] [char](3) NOT NULL,
    [Slot] [char](3) NOT NULL,
    [locLevel] [char](2) NOT NULL,
    [Bin] [char](2) NOT NULL,
    [Extra] [char](2) NOT NULL,
    [LocNumber] [char](2) NOT NULL,
    [RollNumber] [char](20) NOT NULL,
    [QuickRoll] [int] NOT NULL,
    [SkidNumber] [char](15) NOT NULL,
    [RollsInStock] [int] NOT NULL,
    [LocQtyOnHand] [float] NOT NULL,
    [LocQtyOnOrder] [float] NOT NULL,
    [LocQtyCommited] [float] NOT NULL,
    [TotalReceived] [float] NOT NULL,
    [TotalIssued] [float] NOT NULL,
    [TotalDollars] [float] NOT NULL,
    [Capacity] [float] NOT NULL,
    [AvailableSpace] [float] NOT NULL,
    [bkey0] [char](30) NULL,
    [bkey1] [char](30) NULL,
    [bkey2] [char](30) NULL,
    [bkey3] [char](14) NULL,
    [LastPhysicalCountDate] [datetime] NULL,
    [LastCycleCountDate] [datetime] NULL,
    [EnteredBy] [varchar](50) NULL,
    [EnteredDateTime] [datetime] NULL,
CONSTRAINT [IX_InventoryLocations_1] UNIQUE NONCLUSTERED 
(
    [LocItemNumber] ASC,
    [WareHouse] ASC,
    [Aisle] ASC,
    [Slot] ASC,
    [locLevel] ASC,
    [Bin] ASC,
    [Extra] ASC,
    [RollNumber] ASC,
    [SkidNumber] ASC
));

And when trying to insert the following rows, I get the error message.
Inside a cursor which populates the variables.

INSERT INTO [AVANTISERVER\NCL_MASTER].[Avanti].[dbo].[InventoryLocations](LocItemNumber, WareHouse, Aisle, Slot, locLevel, Bin, Extra, RollNumber, LocQtyOnHand, SkidNumber)
            SELECT @item, 'F', 'L', 'E', 'X', 'O', @seq, @seq, @qty, @seq
            FROM FI_CurrentReceiptData CR

Which works out to:

VALUES('MW1', 'F', 'L', 'E', 'X', 'O', 0, 0, 10, 0)
VALUES('MW1', 'F', 'L', 'E', 'X', 'O', 1, 1, 10, 1)

Msg 2627, Level 14, State 2, Line 34 Violation of UNIQUE KEY
constraint ‘IX_InventoryLocations_1’. Cannot insert duplicate key in
object ‘InventoryLocations’.

Please help me to understand why I cannot make these insertions? I am not experienced with these sort of complex constraints. What does this one mean (in simple terms) and how can I get around it? Am I actually violating the constraint?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:52:52+00:00Added an answer on May 25, 2026 at 11:52 am

    All of the items in your SELECT list are constant expressions.

    INSERT INTO [AVANTISERVER\NCL_MASTER].[Avanti].[dbo].[InventoryLocations](LocItemNumber, WareHouse, Aisle, Slot, locLevel, Bin, Extra, RollNumber, LocQtyOnHand, SkidNumber)
                SELECT @item, 'F', 'L', 'E', 'X', 'O', @seq, @seq, @qty, @seq
                FROM FI_CurrentReceiptData CR
    

    I’m not sure why you expect it to differ between rows but in any event it won’t. Perhaps you meant to reference a column rather than a variable somewhere.

    As you say in the comments these variables are being updated in a cursor presumably your SELECT is returning multiple rows FROM FI_CurrentReceiptData. Comment out the Insert and look at the results and see how many rows are returned. Or just remove FROM FI_CurrentReceiptData CR entirely as the SELECT doesn’t use anything from it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table like this: CREATE TABLE [dbo].[Scores]( [Id] [int] IDENTITY(1,1) NOT NULL,
We have the following table: CREATE TABLE [dbo].[CampaignCustomer]( [ID] [int] IDENTITY(1,1) NOT NULL, [CampaignID]
We have the following table: CREATE TABLE [dbo].[CampaignCustomer]( [ID] [int] IDENTITY(1,1) NOT NULL, [CampaignID]
I have a table described as CREATE TABLE [dbo].[Project]( [id] [int] IDENTITY(1,1) NOT NULL,
I have a table that looks like this: CREATE TABLE [dbo].[StudentTime] ([StudentTimeID] [int] NOT
Here's my table schema [dbo].[Action_History]( [ActionID] [int] IDENTITY(1,1) NOT NULL, [objectID] [int] NOT NULL,
I have this table structure: CREATE TABLE users ( uid bigint NOT NULL, first_name
HI ! This is my table: CREATE TABLE [ORG].[MyTable]( .. [my_column2] UNIQUEIDENTIFIER NOT NULL
This is the constraint I have on the Customers table. ALTER TABLE Customers ADD
Let's say my table structure looks something like this: CREATE TABLE [dbo].[table1] ( [id]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.