2013-05-21 38 views
0

嗨SQL我有這樣插入單個XML元素到像字符串操作

<pictures> 
<mainimg> 
<link>http://s.freshnewtracks.com/wp-content/uploads/2012/07/dr_dre_20011.jpeg</link> 
</mainimg> 
<img> 
<title>back</title> 
<link>http://s.freshnewtracks.com/wp-content/uploads/2012/07/dr_dre_20011.jpeg</link> 
</img> 
<web></web> 
<twitter></twitter> 
<facebook></facebook> 
<myspace></myspace> 
<about></about> 
</pictures> 

我需要插入這個XML轉換爲SQL數據表,而無需使用磁盤上的XML文件的XML文件。我已經看到了其他例子,它是通過在磁盤上使用xml文件完成的。我想與類型化/串XML做到這一點,但不保存到磁盤/ BULK Link對於例如像

INSERT INTO Table (XMLColumn) 
VALUES (XML LIKE STRING) 

這可能嗎?我可以對每行的XML文件的元素進行一些控制嗎?

+0

您應該能夠使用參數化SQL使用SqlDbType.Xml參數類型。您是否在尋找像http://stackoverflow.com/questions/3557882/stored-procedure-pass-xml-as-an-argument-and-insert-key-value-pairs/3558102#3558102和http:// stackoverflow.com/questions/3600091/how-to-pass-xml-from-c-sharp-to-a-stored-procedure-in-sql-server-2008?lq=1 – dash

回答

1

通過這個XML作爲字符串存儲過程 和存儲過程

在SP獲得通過@XML XML = null,則此XML字符串:

​​