我在想以下哪兩種方法是在我的xml變量的列上篩選的更好方法。T-SQL篩選器XML變量
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
通知WHERE子句,一個用途存在,另一個使用值,或者是有這是更有效的第三方法?
謝謝,勞爾
假設「更好」意味着「執行更好」,您是否嘗試過查看兩者的查詢計劃? – 2010-09-07 16:46:30