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 |
|
maximus007
Starting Member
18 Posts |
Posted - 2009-05-18 : 15:18:30
|
| Hi this is max. when i write this simple statement in sql it works fine example. "select * from table1" I get no error. However If i were to write it like this "select * from table1 for xml path" I get an erro say: Line 1: Incorrect syntax near 'path'. I were to "for xml auto" it work. I don't understand why this is happening. |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2009-05-19 : 04:12:05
|
If you specify the PATH, you haved to tell it the attributes for the path. You are not doing this with a select *Taken from http://www.programmersheaven.com/2/SQL-server-2005-school-lesson-5 (as i'm having trouble getting on msdn for some reason this morning).quote: PATH mode SQL Server 2005 introduces PATH mode FOR XML queries. When using PATH mode, you specify column names using an XPath-like syntax to map values to attributes, elements, subelements, text nodes, and data values. This makes it possible to generate complex XML without an EXPLICIT mode query. The following example shows how to use PATH mode. SELECT ProductID AS "@ProductID", Name AS "*", Size AS "Description/@Size", Color AS "Description/text()" FROM Production.Product FOR XML PATH
|
 |
|
|
maximus007
Starting Member
18 Posts |
Posted - 2009-05-19 : 09:29:02
|
| Hi Rick this was just an example but I specify the attributes like the following "select test1, test2 from mytable for xml path" and it still didn't work. I use 2005 sql server management studio express which is the free version. Do you think that would be the reason why it's not working? thanks max |
 |
|
|
maximus007
Starting Member
18 Posts |
Posted - 2009-05-19 : 11:01:32
|
| Gentlemen I figured it out. It because I am using sql server 2000 and sql server 2005.Thank you max |
 |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2009-05-19 : 11:51:01
|
Yeah, that would be an issue. |
 |
|
|
|
|
|