stored procedures - Filter Record and insert row by array of ids in SQL Server -


i have created stored procedure.

create procedure [dbo].[proccustomorderhourstasklog]( @worklogids nvarchar(max) = null, --a list of worklog ids (comma-separated list). e.g. 1,2,3 @batchid int = 0 ) 

i have table customorderhourstasklog in have column worklogid.

the stored procedure needs filter @worklogids. array of @worklogids, if given id in customorderhourstasklog table, has nothing.

but if id not exit in customorderhourstasklog table, has insert row customorderhourstasklog table. want check @worklogids 1 one in customorderhourstasklog table. have do. may loop. please me

i think need more specific, if got want:

    create procedure insert_employees     @init_id int,     @end_id  int          begin          create table #array (id int)          while @init_id <= @end_id         begin             insert #array values(@init_id)             set @init_id = @init_id + 1         end          insert employee          select id #array         not exists (select id employee id = a.id)      end 

then execute (example):

    exec insert_employees 1, 10 

Comments