title: T-SQL Filter XML Variable
body: <p>I was wondering which one of the following two was the better way of filtering on a column in my xml variable.</p>
  
  <pre><code>INSERT INTO [Tracking].[Team]([Name], [Description], [Begin_Dt], [End_Dt], [Update_Dt])
  SELECT 
          x.[Team].value('Name', 'varchar(100)') AS [Name],
          x.[Team].value('Description', 'varchar(250)') AS [Description],
          x.[Team].value('Begin_Dt', 'datetime') AS [Begin_Dt],
          x.[Team].value('End_Dt', 'datetime') AS [End_Dt],
          getdate() as [Update_Dt]
  FROM @xml.nodes('/Team') x([Team])
  WHERE x.[Team].value('Team_Ref_ID', 'int') = 0
  
  
  INSERT INTO [Tracking].[Team]([Name], [Description], [Begin_Dt], [End_Dt], [Update_Dt])
  SELECT 
          x.[Team].value('Name', 'varchar(100)') AS [Name],
          x.[Team].value('Description', 'varchar(250)') AS [Description],
          x.[Team].value('Begin_Dt', 'datetime') AS [Begin_Dt],
          x.[Team].value('End_Dt', 'datetime') AS [End_Dt],
          getdate() as [Update_Dt]
  FROM @xml.nodes('/Team') x([Team])
  WHERE x.[Team].exist('Team_Ref_ID[. = 0]') = 1
  </code></pre>
  
  <p>Notice the WHERE clause, one uses exist, the other uses value, or is there a third method that's more effective ?</p>
  
  <p>Thanks,
  Raul</p>