Help with copying columns

  • The following code results in a message stating that the column "Employee" in table EM does not accept nulls.  As far as I can tell, I am not trying to update that field.  Can someone tell me why this is happening?  Thanks a lot!   -S

    INSERT INTO EM(Address1, City, State, ZIP)

    SELECT StreetAddress,City,State,ZipCode

    FROM

    Employees_Home_Address

  • When you insert data using insert into, a null value is submitted for the columns which are not specified in the list of columns. Employee column in EM table might be set to not allow nulls hence you are running in the error above.

  • Problem Solved - thanks! (code)

    update EM

    set  EM.Address1 = Employees_Home_Address.StreetAddress,EM.[City] = Employees_Home_Address.[City],EM.[State] = Employees_Home_Address.[State],EM.ZIP = Employees_Home_Address.ZipCode

    FROM

    EM

    INNER JOIN

    Employees_Home_Address

    ON

    EM.Employee = Employees_Home_Address.Employee

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply