title: update empty fields to Null but failed with NullIF or len(trim())=0
body: <p>I imported 4 flat flies into 4 sql tables. All the files has 77 columns. After import, I need to update empty fields to Null for all 4 tables. Below is the syntax:</p>
  
  <pre><code>DECLARE @iCount as integer
  DECLARE @sCol1 as varchar(50)
  
  --Replace all empty fields with NULL value
  
  --Update audWeeklycs
  Set @iCount =0
  While @iCount&lt;=76
  Begin
    if @iCount &lt;=9
    set @sCol1='[Col00'+CAST(@iCount as varchar (2))+']'
    else 
    set @sCol1='[Col0'+cast(@iCount as varchar (2))+']'
  
    Update MHP_Analysis.dbo.audWeeklycs
    Set @sCol1= case when len(rtrim(ltrim(@sCol1)))=0 then Null else @sCol1 end
    Set @iCount=@iCount+1
  End
  </code></pre>
  
  <p>After run this statement, I found there is no change for empty fields. Can't figure out why. I also tried NULLIF function and didn't work.</p>