Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Select

Author  Topic 

rcmpayne
Starting Member

1 Post

Posted - 2009-07-03 : 07:39:01
Hello All,

I am making a select statement to pull some info and would like to do the following.

In a table I have a column called Data and it has the following info
<R><t2>-100</t2><t3>4241713</t3><t4>100</t4><t5>432005</t5></R>

I would like to make a querry to only show the information for t3

<T3>4241713</T3>

So select * from Table where Tableid = ‘5’ show the full data row.
<R><t2>-100</t2><t3>4241713</t3><t4>100</t4><t5>432005</t5></R>


I hope this makes since

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-07-03 : 07:57:06
[code]DECLARE @Sample TABLE
(
ID INT IDENTITY(1, 1) PRIMARY KEY CLUSTERED,
Data XML
)

INSERT @Sample
SELECT '<R><t2>-100</t2><t3>4241713</t3><t4>100</t4><t5>432005</t5></R>'

SELECT ID,
Data,
Data.value('/R[1]/t3[1]', 'INT') AS t3
FROM @Sample[/code]


Microsoft SQL Server MVP

N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -