Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

Update not working

$
0
0

using sql 2008.

I am running an update statement and then sunning a select with the same join and where clause as in the update statement but my target table values are different from what I expected. When I ran the select after the update I expect all agent number in f_iSummary to be the same as in I_premium  so the select statement should not return any rows, but it does. 

Is there something I am missing in the select statement which I am using to verify my update?

Thanks for you help.   

<code>
  Update f
  set f.agent_nbr = i.agent_nbr
 FROM 
  dbo.f_iSummary f
  Join I_premium i on 
  LTRIM(RTRIM(f.policy)) = LTRIM(RTRIM(i.policy))
  and LTRIM(RTRIM(f.edition)) = LTRIM(RTRIM(i.edition))
  and LTRIM(RTRIM(f.policy_key)) = LTRIM(RTRIM(i.policy_key))
  AND LTRIM(rTRIM(F.unit_number)) = LTRIM(RTRIM(I.UNIT_NUMBER))
  and LTRIM(RTRIM(i.book_period)) = '20150412'
  and f.timeID = 1169  
  where 
  f.timeID = 1169
  and   LTRIM(RTRIM(i.book_period)) = '20150412'


  Select distinct F.POLICY, F.POLICY_KEY, F.EDITION, F.UNIT_NUMBER, F.timeID, I.book_period, f.districtID, f.agent_nbr , i.agent_nbr
 FROM 
  dbo.f_iSummary f
  Join I_premium i on 
  LTRIM(RTRIM(f.policy)) = LTRIM(RTRIM(i.policy))
  and LTRIM(RTRIM(f.edition)) = LTRIM(RTRIM(i.edition))
  and LTRIM(RTRIM(f.policy_key)) = LTRIM(RTRIM(i.policy_key))
  AND LTRIM(rTRIM(F.unit_number)) = LTRIM(RTRIM(I.UNIT_NUMBER))
  and LTRIM(RTRIM(i.book_period)) = '20150412'
  and f.timeID = 1169  
  where 
  f.timeID = 1169
  and   LTRIM(RTRIM(i.book_period)) = '20150412'
  and f.agent_nbr <> i.agent_nbr

</code>


Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>