Click here to Skip to main content
15,890,741 members
Home / Discussions / Database
   

Database

 
GeneralRe: Atomic Sql Statements (Transaction) Pin
PIEBALDconsult5-Nov-08 13:33
mvePIEBALDconsult5-Nov-08 13:33 
GeneralRe: Atomic Sql Statements (Transaction) Pin
Wendelius6-Nov-08 7:39
mentorWendelius6-Nov-08 7:39 
GeneralRe: Atomic Sql Statements (Transaction) Pin
PIEBALDconsult6-Nov-08 11:27
mvePIEBALDconsult6-Nov-08 11:27 
GeneralRe: Atomic Sql Statements (Transaction) Pin
Wendelius7-Nov-08 6:36
mentorWendelius7-Nov-08 6:36 
Questionsql server 2005 query xml datatype fields Pin
arkiboys5-Nov-08 2:55
arkiboys5-Nov-08 2:55 
AnswerRe: sql server 2005 query xml datatype fields Pin
Wendelius5-Nov-08 10:33
mentorWendelius5-Nov-08 10:33 
GeneralRe: sql server 2005 query xml datatype fields Pin
arkiboys5-Nov-08 10:54
arkiboys5-Nov-08 10:54 
GeneralRe: sql server 2005 query xml datatype fields Pin
Wendelius5-Nov-08 11:13
mentorWendelius5-Nov-08 11:13 
That wasn't exactly my point.

Enclose field named xml in brackets (is that correct word for [ and ]?) like:
CROSS APPLY s.[xml].nodes...

Then if you run the query you have, you'll get empty results. But if you have an alias (like A) for the namespace, the query runs fine:
...xmlns:A="http:...

Also you don't have to use namespace in the xquery.

Here's the full code:
DECLARE @Sample TABLE
(
rowID INT IDENTITY(1, 1) PRIMARY KEY CLUSTERED,
[xml] XML
)

INSERT @Sample
SELECT '<stringList xmlns:A="http://schemas.myCompany.com/myProject/[app]/stringList/1.0"><value>value1</value></stringList>' UNION ALL
SELECT NULL UNION ALL
SELECT '<stringList xmlns:A="http://schemas.myCompany.com/myProject/[app]/stringList/1.0"><value>value5</value><value>value2</value></stringList>' UNION ALL
SELECT '<stringList xmlns:A="http://schemas.myCompany.com/myProject/[app]/stringList/1.0"><value>value4</value><value>value1</value><value>value5</value><value>value2</value></stringList>'

SELECT *
FROM @Sample

SELECT DISTINCT t.c.value('.', 'VARCHAR(20)')
FROM @Sample AS s
CROSS APPLY s.[xml].nodes('/stringList/value') AS t(c)


The need to optimize rises from a bad design.

My articles[^]

GeneralRe: sql server 2005 query xml datatype fields Pin
arkiboys6-Nov-08 1:50
arkiboys6-Nov-08 1:50 
GeneralRe: sql server 2005 query xml datatype fields Pin
Wendelius6-Nov-08 7:06
mentorWendelius6-Nov-08 7:06 
Questiontransfering data fro one table to another Pin
prasadbuddhika5-Nov-08 1:07
prasadbuddhika5-Nov-08 1:07 
AnswerRe: transfering data fro one table to another Pin
Ashfield5-Nov-08 1:34
Ashfield5-Nov-08 1:34 
GeneralRe: transfering data fro one table to another Pin
prasadbuddhika5-Nov-08 16:08
prasadbuddhika5-Nov-08 16:08 
GeneralRe: transfering data fro one table to another Pin
Ashfield5-Nov-08 21:01
Ashfield5-Nov-08 21:01 
GeneralRe: transfering data fro one table to another Pin
Muditha Dissanayake6-Nov-08 4:39
Muditha Dissanayake6-Nov-08 4:39 
Questionwhere can i find the northwind sql script Pin
prasadbuddhika4-Nov-08 23:58
prasadbuddhika4-Nov-08 23:58 
AnswerRe: where can i find the northwind sql script Pin
cyber-drugs5-Nov-08 0:12
cyber-drugs5-Nov-08 0:12 
GeneralRe: where can i find the northwind sql script Pin
prasadbuddhika5-Nov-08 0:34
prasadbuddhika5-Nov-08 0:34 
GeneralRe: where can i find the northwind sql script Pin
cyber-drugs5-Nov-08 0:41
cyber-drugs5-Nov-08 0:41 
AnswerRe: where can i find the northwind sql script Pin
Wendelius5-Nov-08 10:38
mentorWendelius5-Nov-08 10:38 
QuestionFiltering Query results Pin
Andy_L_J4-Nov-08 23:28
Andy_L_J4-Nov-08 23:28 
AnswerRe: Filtering Query results Pin
J4amieC5-Nov-08 0:57
J4amieC5-Nov-08 0:57 
GeneralRe: Filtering Query results Pin
Andy_L_J5-Nov-08 1:36
Andy_L_J5-Nov-08 1:36 
QuestionError while executing Query Pin
praveenkumar_k4-Nov-08 20:50
praveenkumar_k4-Nov-08 20:50 
AnswerRe: Error while executing Query Pin
Wendelius5-Nov-08 10:43
mentorWendelius5-Nov-08 10:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.