>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.