title: Time taken by trigger for GetDate vs time taken for Milliseconds in SQL
body: <p>I was doing the performance test of GetDate vs milliseconds in SQL. I run a trigger which inserts current time in field on update.</p>
  
  <pre><code>CREATE TRIGGER updateDate ON sm_activity 
  AFTER UPDATE
  AS
  BEGIN
     UPDATE sm_activity SET LastUpdate = GETDATE()
     FROM sm_activity INNER JOIN inserted i ON 
     i.id =sm_activity.id
  END
  </code></pre>
  
  <p>And run update query on 10000 rows. It took 34431 milliseconds while when I used milliseconds in trigger that is</p>
  
  <pre><code>CREATE TRIGGER updateDate ON sm_activity 
  AFTER UPDATE
  AS
  BEGIN
     UPDATE sm_activity SET LastUpdate = (CAST(DATEDIFF(second, '1970-01-01', CAST(GETUTCDATE() AS date)) AS bigint)*1000) + DATEDIFF(ms, CAST(GETUTCDATE() AS date), GETUTCDATE()) 
     FROM sm_activity INNER JOIN inserted i ON 
     i.id =sm_activity.id
  END
  </code></pre>
  
  <p>For the same number of rows, it took 15124 milliseconds. How is it possible that GetDate() is taking double of milliseconds even though milliseconds are being calculated by using GetDate.</p>