2015-11-11 57 views
1
ID Status LOAD 
1 Active <root><Loan>1001</Loan><Atty>False</Atty></root> 
2 Failed <root><Loan>1021</Loan><Atty>True</Atty></root> 
3 Failed <root><Loan>1004</Loan><Atty>True</Atty></root> 
4 Active <root><Loan>1034</Loan><Atty>True</Atty></root> 

在這裏,我想獲得貸款號= 1004的狀態,ID和LOAD。 我們如何創建sql查詢? 加載列是XML類型。帶有where子句和select的SQL Server XML

回答

3

SELECT 
    ID, [Status], [Load] 
FROM 
    dbo.YourTableNameHEre 
WHERE 
    Load.value('(/root/Loan)[1]', 'int') = 1004