Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Inserting Records on Primary Key

Author  Topic 

gemispence
Yak Posting Veteran

71 Posts

Posted - 2006-02-16 : 16:16:29
I'm getting a foreign key error as well as Indentity Insert error when I'm trying to run a stored proc that inserts values from another table..help!!

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-02-16 : 16:17:49
You are probably trying to insert child data prior to the parent being inserted. We'll need to see the data in order to help though.

Tara Kizer
aka tduggan
Go to Top of Page

gemispence
Yak Posting Veteran

71 Posts

Posted - 2006-02-16 : 16:51:24
This is what I'm trying to do:
I'm trying to insert data from one table into another. The problem is that I'm getting an error saying that the Primary Key doesn't accept nulls. How do I approach this without allowing nulls into this field.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-02-16 : 16:53:33
Well you can't insert a NULL value into a column that is part of the primary key. There is no way to get around this. You need to provide a non-NULL value for this to work.

Tara Kizer
aka tduggan
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-02-17 : 00:38:30
>>as well as Indentity Insert error

Also you need to omit identity column when inserting values to that table

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -