Primary Key Error | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Primary Key Error

hai CREATE TABLE [AircraftManufacturer] (
[SolisID] [int] NOT NULL ,
[vcMarketerAccNo] [nvarchar] (100) COLLATE SQL_Latin1_General_CP850_CI_AI NOT NULL ,
[MfrName] [nvarchar] (500) COLLATE SQL_Latin1_General_CP850_CI_AI NOT NULL ,
CONSTRAINT [PK_AircraftManufacturer] PRIMARY KEY NONCLUSTERED
(
[SolisID]
) WITH FILLFACTOR = 90 ON [PRIMARY] ,
CONSTRAINT [FK_AircraftManufacturer_DM] FOREIGN KEY
(
[SolisID]
) REFERENCES [T_DirectoryMarketer] (
[iMarketerID]
)
) ON [PRIMARY]
GO This is My Table Structure When I insert Dublicate Value, it will give Error like
Violation of PRIMARY KEY constraint ‘PK_AircraftManufacturer’. Cannot insert duplicate key in object ‘AircraftManufacturer’.
The statement has been terminated.
But I need to insert Dublicate Value without changing table structure ..what can i do.. S.Gnana Prakash
hi
Remove primary key cmd
drop CONSTRAINT PK_AircraftManufacturer
Thanks
S. Ramesh
You can’t have duplicates in primary keys. Either you drop the primary key or not insert any duplicates —————————————-
Contributing Editor, Writer & Forums Moderator
http://www.SQL-Server-Performance.Com Visit my Blog at
http://dineshasanka.spaces.live.com/

hai but i amn not possible to remove primary key… because another table is refering this filed Id(foreign key) S.Gnana Prakash
See the definition of the PK from BOL
primary key (PK)
A column or set of columns that uniquely identify all the rows in a table. Primary keys do not allow null values. No two rows can have the same primary key value; therefore, a primary key value always uniquely identifies a single row. More than one key can uniquely identify rows in a table, each of these keys is called a candidate key. Only one candidate can be chosen as the primary key of a table; all other candidate keys are known as alternate keys. Although tables are not required to have primary keys, it is good practice to define them. In a normalized table, all of the data values in each row are fully dependent on the primary key. For example, in a normalized employee table that has EmployeeID as the primary key, all of the columns should contain data related to a specific employee. This table does not have the column DepartmentName because the name of the department is dependent on a department ID, not on an employee ID. so , you have to think of your db design —————————————-
Contributing Editor, Writer & Forums Moderator
http://www.SQL-Server-Performance.Com Visit my Blog at
http://dineshasanka.spaces.live.com/

A primary key is the cornerstone of relational database design. No PK, no sensible data. If you are asked to insert duplicate values into a PK, then there is a flaw in the design of the table.
>>But I need to insert Dublicate Value without changing table structure ..what can i do.. No you cant. Why do you want not to alter the table? Then what is the point of having Primary key?
Madhivanan Failing to plan is Planning to fail
I am not sure if this is correct but I think you want to have another column for the primary key and not the SolisID. By assigning a REFERENCE constraint, you are basically saying that SolisID is child (meaning can have multiple instances or in otherwords, duplicates). If you want to move on, create a column, use the IDENTITY function to generate unique values and assign it as PK column. Hope this helps. May the Almighty God bless us all!
www.empoweredinformation.com
]]>