i have this queryINSERT INTO LEVCompaniesDepartment (UserID,DepartmentID) SELECT 422,170 UNION ALL SELECT 422,320 UNION ALL SELECT 422,520 where not EXISTS (select UserID from LEVCompaniesDepartment where UserID=422 and DepartmentID=170 UNION ALL SELECT 422,320 UNION ALL SELECT 422,520
what i did using union i wanted to inset in ONE STEP lots of DepartmentID to a user,but i need to check for each one ofthem if the cmbination of (UserID,DepartmentID) exist beacuse i have them both as PRIMARY KEYS!!what can i ddo?the above query is build "dynamicly" where i use a trick from an answer i got here to use union on a variable like @depid where it willgive ma a ready made query of all select to insert onceso what can i do?thnaks in advancepelegIsrael -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)