Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Load statement
Message
De
01/10/2007 17:47:29
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Load statement
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01257797
Message ID:
01257797
Vues:
57
I have two tables: Employee and TempEmployee. TempEmployee comes from another source and has an ID field, and EmployeeID field, and an EmployeeName field. Employee has those same fields plus a ScreenOrder field.

I want to come up with a statement that will insert the record into Employee if it doesn't already exist but does exist in TempEmployee as keyed by EmployeeID. I want the ScreenOrder field to always be the maximum value + 1.

I can show the records like so:
SELECT * FROM TempEmployee WHERE EmployeeID NOT IN (SELECT EmployeeID FROM Employee)
but I don't know how to insert those records into Employee without creating a temporary table and looping through it. Is there an easy way I don't know about?

Thanks!

(Sorry about the thread title - I forgot to rename it to something descriptive after I typed the message)
Very fitting: http://xkcd.com/386/
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform