SQL error violation of PK_constraint

I have Access front end and SQL back end database. I am trying to synch 2
tables together, insert records from table1 into table2 if they do not exist
in table2, if they exist, then update.
The primary key is set to the empID. I have some records that need to be
inserted into table2, however, I am getting an error that can not insert Null
value, empID column does not allow nulls.
The records do not have any fields that are null so I am not sure what is
going on.
When I try to append those records in access, they append fine. But I really
need to get this to work in SQL. Can someone give me an advise on what may be
going on?

thanks
HarterAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

pcelbaCommented:
We don't know your data and environment so the easiest solution is to start the SQL Server Profiler and look what command and values is Access trying to insert.
0
Chris LuttrellSenior Database ArchitectCommented:
It sounds like the insert statement is not providing the value for empID for table2, it should be something like this:
insert into table2 (empID, othercols)
select empID, othercols
from table1
where not exists (select 'x' from table2 where table1.empID = table2.empID)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KelevraCommented:
Hi,

Try
    {
        go to (in Viual Studio), Tool,
                                            Options...,
                                            DataBaseTools,
                                            DataBase and table conception,
                                            Options of Scema and Table,

                                            untick the 6th checkbox from the top: Avoid Record modification ...
}

mind that my Visual Studio is not in english, so, I might have the Menu's name mispelled.
Hope this'll help
0
HarterAuthor Commented:
I would like to thank experts pcelba, CGLuttrell and Kelevra for responding to my question. I ended up rewriting my sp per CGLuttrell's suggestion.
thanks a lot!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Databases

From novice to tech pro — start learning today.