2013-03-14 26 views
1

存在包含XML數據的名爲FileImage的列。如何在Sql Server中使用Xquery來搜索存儲XML數據的列中的字符

<root> 
    <Image>  
    <File_image>02Jan12- Mfg--7.jpg</File_image> 
    <Page_no>7</Page_no> 
    <Logo>N</Logo> 
    </Image> 
</root> 

我想搜索標籤之間的文本是否包含空格字符。 這是爲了檢查無效的文件名。

SELECT * 
FROM mytable 
where fileimage.exist(' 
    /Image:file_image//text() 
    [contains(., " ")]') = 1 

但是示出錯誤
的XQuery [mytable.FileImage.exist()]:名稱 「圖像」 不表示命名空間。

如何做到這一點?我正在使用SQL Server 2005.

回答

2
SELECT * 
FROM mytable 
where fileimage.exist(' 
    /root/Image/File_image//text() 
    [contains(., " ")]') = 1 
+0

謝謝了,IronMan !!!!! – 2013-03-14 06:45:22

+0

不客氣) – revoua 2013-03-14 06:49:36

相關問題