Results 1 to 23 of 23

Thread: [RESOLVED] Composite Table Issues - Does not match table definition

Threaded View

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Resolved [RESOLVED] Composite Table Issues - Does not match table definition

    Hi, all,

    I have a composite table called TicketAuthors that has four columns. Three of those are set to primary key. I have found that you can't have a NULL value with a composite table with multiple primary keys.
    The issue I am having is that I am using a stored procedure to check to see if the name exists, if it doesn't, then to add the name.

    Only problem is, I am getting the error in the attached screen shot.
    I have found that the table is removing the identity specification for two of the three primary key columns.
    I am not sure what to do about this as this is the first time I am working with a composite primary key.
    I have been searching for hours for a resolution and haven't found one yet.

    Stored Procedure:
    Code:
    ALTER PROCEDURE dbo.CheckTicketAuthorExists(@User VARCHAR(250))
    AS
    BEGIN
    IF (SELECT COUNT(*) FROM TicketAuthors WHERE TicketAuthors = @User) = 0
    BEGIN
    INSERT INTO TicketAuthors
    VALUES(@User)
    END
    END
    Table setup:
    Code:
    CREATE TABLE [dbo].[TicketAuthors](
    	[CreatedByID_PK] [int] NOT NULL,
    	[LastModifiedByID_PK] [int] NOT NULL,
    	[BeingViewedByID_PK] [int] IDENTITY(1,1) NOT NULL,
    	[TicketAuthors] [varchar](250) NOT NULL,
     CONSTRAINT [PK_TicketAuthors] PRIMARY KEY CLUSTERED 
    (
    	[CreatedByID_PK] ASC,
    	[LastModifiedByID_PK] ASC,
    	[BeingViewedByID_PK] ASC
    )WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
    ) ON [PRIMARY]
    All the three public key columns need to have the same value. Please advise as to your thoughts on how to get this working.
    Attached Images Attached Images  

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