sqlsrv update where not all passed vars have data -


i making form employees update demographics, address, phone, email, etc. information placed in processing table processed on file on mondays. didn't want place multiple lines in processing table 1 person, scenario comes in on tuesday new address , comes on thursday new phone, gets updated on same line. i've done this:

update pendingprocessing  set street1 = isnull(nullif('{$addr1}',''), street1),      street2 = isnull(nullif('{$addr2}',''), street2),      email = isnull(nullif('{$email}',''), email),      cellphone = isnull(nullif('{$cellphone}',''), cellphone),      homephone = isnull(nullif('{$homephone}',''),homephone),      city = isnull(nullif('{$city}',''), city),      state = isnull(nullif('{$state}',''),state),      zip = isnull(nullif('{$zip}',''),zip),      dateofchangerequest = '{$date}'   clock = '{$username}';    if (@@rowcount = 0)  begin      if (not exists( select * pendingprocessing  clock = '{$username}' ))     begin          insert pendingprocessing          (             clock,              street1,              street2,               email,              cellphone,              homephone,              city,              state,              zip,              dateofchangerequest         )          values          (             '{$username}',              '{$addr1}',             '{$addr2}',             '{$email}',             '{$cellphone}',             '{$homephone}',             '{$city}',             '{$state}',             '{$zip}',             '{$date}'         );      end;  end; 

but problem if there address in street1 column when phone number comes in leaves first character in street1.

the short way make user enter new address again when entering new phone number because first address update still pending processing. prefer make code work though.

so, question how can update columns when have data update them with? don't want null existing data, don't want not update has data, user entered new phone number , realized after saving had made typo , needed change number. help.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -