Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to question
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Environment versions
SQL Server:
SQL Server 2000
Miscellaneous
Thread ID:
01100909
Message ID:
01100949
Views:
14
>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.
Previous
Reply
Map
View

Click here to load this message in the networking platform