On Feb 15, 9:09 am, "el" <eldrickva...@hotmail.com> wrote:
> On Feb 15, 2:08 am, "Jens" <J...@sqlserver2005.de> wrote:
>
>
>
>
>
> > On 14 Feb., 22:28, "el" <eldrickva...@hotmail.com> wrote:
>
> > > I started with a CSV file which I imported into SQL to create a table.
> > > My initial table is employees (ID, LastName, FirstName, Department,
> > > Division, Title, OfficePhone, MobilePhone, Login). The new table is
> > > called employees_update ( LastName, FirstName, Login, OfficePhone).
> > > I need to update the employees table (374 records) with the info in
> > > the employees_update table (193 records).
> > > I need SQL to:
> > > 1. Update the records in the employees table from the
> > > employees_update table
> > > 2. Insert new records into the employees table from the
> > > employees_update table
>
> > UPDATE employees
> > SET Col1 = A.Col1 (Rest of the Update goes here)
> > FROM employees
> > INNER JOIN employees_Update A
> > ON employees.YourPK = A.YourPK
>
> > And so the insert
>
> > INSERT INTO employees
> > (ColumnListHere)
> > SELECT
> > columnlisthere
> > FROM employees_Update
> > WHERE NOT EXISTS
> > (
> > SELECT * FROM employees WHERE employees.YourPK =
> > employees_Update.YOurPK
> > )
>
> > HTH, Jens K. Suessmeyer.
>
> > ---
http://www.sqlserver2005.de > > ---
>
> I was able to get the update to work but the insert is giving me the
> error:
> Server: Msg 2809, Level 18, State 1, Line 1
> The request for procedure 'Employees' failed because 'Employees' is a
> table object
>
> The line is INSERT INTO Employees- Hide quoted text -
>
> - Show quoted text -
I figured out my problem. It worked perfectly. Thank you for the