| Author |
Topic |
|
Apples
Posting Yak Master
146 Posts |
Posted - 2008-09-05 : 17:23:31
|
| Here's my table I'm working with:-----------------------------------------------------Products-----------------------------------------------------ProductID | Description | Review-----------------------------------------------------The data contained in the column Description is HTML. The Review for the product is in that column as well, but now it needs to be stored in the new column named Review. What I need to do is pull the HTML containing the Review out of the Description column and put it in the new column for all the existing Products in the DBHere's how the HTML would look in Description:...there can be any amount of HTML before the review...<div><strong>PRODUCTNAME Review</strong><br />...the text for the Review is in here...</div>...there can be any amount of HTML after the review...So I need to get that div tag and everything inside of it out of the Description column and into the Review column |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-06 : 23:26:49
|
| are you using sql 2005? |
 |
|
|
Apples
Posting Yak Master
146 Posts |
Posted - 2008-09-07 : 21:05:01
|
quote: Originally posted by visakh16 are you using sql 2005?
Yes I am. |
 |
|
|
Apples
Posting Yak Master
146 Posts |
Posted - 2008-09-08 : 11:09:46
|
| Can anyone help me with this? |
 |
|
|
Apples
Posting Yak Master
146 Posts |
Posted - 2008-09-08 : 14:11:55
|
| I'm still having trouble, any help would be appreciated. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-08 : 14:27:29
|
try:-SELECT c.col.value('.','varchar(8000)')FROM yourxmlcolumn.nodes('//div/')c(col) |
 |
|
|
Apples
Posting Yak Master
146 Posts |
Posted - 2008-09-08 : 14:39:42
|
quote: Originally posted by visakh16 try:-SELECT c.col.value('.','varchar(8000)')FROM yourxmlcolumn.nodes('//div/')c(col)
Can you explain what that is doing? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-08 : 14:41:07
|
quote: Originally posted by Apples
quote: Originally posted by visakh16 try:-SELECT c.col.value('.','varchar(8000)')FROM yourxmlcolumn.nodes('//div/')c(col)
Can you explain what that is doing?
this will only work if your column datatype is xml. |
 |
|
|
Apples
Posting Yak Master
146 Posts |
Posted - 2008-09-08 : 14:45:00
|
| The column datatype is ntext |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-08 : 14:49:15
|
quote: Originally posted by Apples The column datatype is ntext
Then you need to use OPENXML. look into books online for syntax and usage. |
 |
|
|
Apples
Posting Yak Master
146 Posts |
Posted - 2008-09-08 : 16:36:34
|
| Surely there's another (simpler) way to do this with substring? |
 |
|
|
|