That worked great. Thank you. Now, one more thing that I need is to condition the the field yaphrt (which is the hourly rate) to be update ONLY if it falls within the authorized business units (from / to) for user running the query.I have following code which updates a temp table. This is based upon user running the query and which business units user are authorized to see:insert into #Authority_Table ( busunit_from, busunit_to )select msmcuf, msmcutfrom OPENQUERY(AS400SRV_MSOLEDB, 'SELECT * FROM vgisec.f0001')where msuser = @UserID and isnumeric(msmcuf) <> 0 and isnumeric(msmcut) <> 0
Now taking the code snippet:update #Work_Tableset employee_rate = yaphrt / 1000, business_unit = yamcufrom #Work_Table join openquery(AS400SRV_MSOLEDB, 'SELECT * FROM vgiprdhrp.f060116') on #Work_Table.employee_id = yaan8
I need to update the hourly rate ONLY if user is authorized to see it like:INNER JOIN #Authority_Table AS at ON at.busunit_from <= yamcu and at.busunit_to >= yamcu
Not sure how to add this to the codeNote: A user may have following authorization list:User Id Business Business units from unists to RGWGMEV 350150 350150 RGWGMEV 350535 350650 RGWGMEV 360010 360015 RGWGMEV 360080 360087 RGWGMEV 640001 640999 RGWGMEV 650001 650999 RGWGMEV 3200000 3209999 RGWGMEV 3500000 3509999 RGWGMEV 3600000 3609999 RGWGMEV 6400000 6409999 RGWGMEV 6500000 6509999