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)
 For Xml Clause

Author  Topic 

swathigardas
Posting Yak Master

149 Posts

Posted - 2008-08-28 : 01:18:11
Hi i want to generate the table data in xml format.

when i write a query like this

SELECT Profile_Id as "@ProfileID",
FRST_NAME as "First Name",
LAST_NAME as "Last Name",
USER_ID as "ID/User",
EMAIL_ID as "Id/Email",
GNDR as "Gender",
CNTCT_NUM as "contact"

FROM dbo.VTX_PRFLE_DTL
FOR XML PATH(' '), ROOT('Details')

it shows an error like these

Msg 170, Level 15, State 1, Line 6
Line 6: Incorrect syntax near 'XML'


..
Can anyone help on this

sunil
Constraint Violating Yak Guru

282 Posts

Posted - 2008-08-28 : 01:39:00
I copied your code in QA and it did not give any error on parsing.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-28 : 04:09:01
quote:
Originally posted by swathigardas

Hi i want to generate the table data in xml format.

when i write a query like this

SELECT Profile_Id as "@ProfileID",
FRST_NAME as "First Name",
LAST_NAME as "Last Name",
USER_ID as "ID/User",
EMAIL_ID as "Id/Email",
GNDR as "Gender",
CNTCT_NUM as "contact"

FROM dbo.VTX_PRFLE_DTL
FOR XML PATH('SomeNameHere'), ROOT('Details')

it shows an error like these

Msg 170, Level 15, State 1, Line 6
Line 6: Incorrect syntax near 'XML'


..
Can anyone help on this


modify like above
Go to Top of Page

swathigardas
Posting Yak Master

149 Posts

Posted - 2008-08-28 : 04:23:06
i modified it with a name..But it still shows the same error.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-28 : 04:31:08
its working fine for me. B/w are you using sql 2005?
Go to Top of Page

swathigardas
Posting Yak Master

149 Posts

Posted - 2008-08-28 : 09:28:43
Ya i'm using sql 2005 only.... but the error is still seen
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-28 : 09:39:33
whats the compatibility level of your db?
Go to Top of Page

swathigardas
Posting Yak Master

149 Posts

Posted - 2008-08-29 : 09:07:17
What do you mean by this compatibility level...
I dint understand this term in regards to SQL server.
How to check it
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-08-29 : 09:13:09
Read Books Online or search Google.
Your current database can have a different compatibility level.



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

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-29 : 10:14:35
use sp_dbcmptlevel to check databse compatibility level
Go to Top of Page

swathigardas
Posting Yak Master

149 Posts

Posted - 2008-09-01 : 02:04:52
hi the compatibility level of the database is 90.That is been shown
Go to Top of Page
   

- Advertisement -