Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to question
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01100909
Message ID:
01100949
Vues:
13
>I'm not sure how to do this exactly, but I'm sure there is a way:
>
>@tiInsertDeptID=55
>@tiStartsWith='IN'
>
>Select the invid from coinv where itemnumber start with @tiStartWith
>Inserting each record if it doesn't already exist for that invid and deptID into
>Insert into coDeptInv (invID,DeptID) values (invID,@tiInsertDeptID)
>
>Thanks for any help.
>
>Kirk
SET @tiInsertDeptID = 55
SET @tiStartsWith   = 'IN%'

INSERT INTO coDeptInv (invID,DeptID) 
SELECT invID, @tiInsertDeptID
       FROM CoInv
       WHERE Invid LIKE @tiStartsWith AND 
             Invid NOT IN (SELECT Invid FROM coDeptInv WHERE DeptID = @tiInsertDeptID)
not tested
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform