即时通讯群人员添加.sql 740 B

12345678910
  1. declare @timdialogusersid bigint
  2. set @timdialogusersid = (select isnull(MAX(timdialogusersid), 0) from timdialogusers)
  3. insert into timdialogusers
  4. (timdialogusersid, siteid, createby, changeby, createdate, changedate, rmkenable, fimdialognotes,fisremove,fname, tenterprise_userid,timdialogid,funreadmsgcount)
  5. select @timdialogusersid + ROW_NUMBER() over (order by t1.fname),
  6. t1.siteid, $createby$, $createby$, getdate(), getdate(), 0, null,0,t1.fname, t1.tenterprise_userid,$timdialogid$,0
  7. from tenterprise_users t1
  8. where t1.siteid=$siteid$ and t1.tenterprise_userid in $tenterprise_userid$
  9. and not exists(select * from timdialogusers where siteid=$siteid$ and timdialogid=$timdialogid$ and tenterprise_userid=t1.tenterprise_userid )