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.
| Author |
Topic |
|
sital
Yak Posting Veteran
89 Posts |
Posted - 2009-01-25 : 06:25:36
|
| I have doubt in the following query.select id,xval from #sub where xval.value('(/subscription/myid)[1]','varchar(9)')=N'12345'This query searches for the XML record which contains the value as '12345'.Why should I write [1] in the above query? Is it necessary to write [1]?Is there any other way in which this can be done? |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
sital
Yak Posting Veteran
89 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-26 : 23:44:43
|
| value requires a singleton node. which is why we need to use [1],[2],.... [1] means first nodeset matching name |
 |
|
|
sital
Yak Posting Veteran
89 Posts |
Posted - 2009-01-27 : 05:02:12
|
quote: Originally posted by visakh16 value requires a singleton node. which is why we need to use [1],[2],.... [1] means first nodeset matching name
Thanks sir.When I try to give [1] it is giving me error?So in which cases I can use [1] and where can I use [2]?Actually I m just learning SQL server so can you please give me detailed information I am very confused with the use of XML datatype in SQL Server. That 's why I m getting many doubts. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-27 : 08:43:57
|
| can you show your code? [1],[2],... represents the position of nodeset, so what you use depends on which node elements value you're interested in. |
 |
|
|
sital
Yak Posting Veteran
89 Posts |
Posted - 2009-01-27 : 11:18:14
|
quote: Originally posted by visakh16 can you show your code? [1],[2],... represents the position of nodeset, so what you use depends on which node elements value you're interested in.
Actually I have deleted that file. So I cannot post it in the forum.Sorry.Thanks a lot for helping out in all my posts in the forum. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-27 : 12:11:23
|
no problem.. |
 |
|
|
|
|
|
|
|