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
 General SQL Server Forums
 New to SQL Server Programming
 For XML add 'T'

Author  Topic 

khalik
Constraint Violating Yak Guru

443 Posts

Posted - 2009-01-23 : 07:22:23
hi

When i execute a query with For XML clause it add a 'T' between data and time. can this be avoided.

LastUpdated="2008-08-09T04:28:57.333"

also one more i created a table

create table testxml(id int ,data xml)

insert into testxml(1,<01card CardID="1" CardName="AccountCategory" CardDescription="Account Category"/>)

i get an error Incorrect syntax near '<'.

how do i insert data in xml column.

Thanks

========================================
Project Manager who loves to code.
===============
Ask to your self before u ask someone

raky
Aged Yak Warrior

767 Posts

Posted - 2009-01-23 : 07:31:52
u can avoid 't' by converting into 121 style using convert function
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-23 : 09:39:03
quote:
Originally posted by khalik

hi

When i execute a query with For XML clause it add a 'T' between data and time. can this be avoided.

LastUpdated="2008-08-09T04:28:57.333"

also one more i created a table

create table testxml(id int ,data xml)

insert into testxml(1,<01card CardID="1" CardName="AccountCategory" CardDescription="Account Category"/>)

i get an error Incorrect syntax near '<'.

how do i insert data in xml column.

Thanks

========================================
Project Manager who loves to code.
===============
Ask to your self before u ask someone


for insertion,just insert like varchar

insert into testxml(1,'<01card CardID="1" CardName="AccountCategory" CardDescription="Account Category"/>')

Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2009-01-23 : 10:13:40
quote:
Originally posted by visakh16

quote:
Originally posted by khalik

hi

When i execute a query with For XML clause it add a 'T' between data and time. can this be avoided.

LastUpdated="2008-08-09T04:28:57.333"

also one more i created a table

create table testxml(id int ,data xml)

insert into testxml(1,<01card CardID="1" CardName="AccountCategory" CardDescription="Account Category"/>)

i get an error Incorrect syntax near '<'.

how do i insert data in xml column.

Thanks

========================================
Project Manager who loves to code.
===============
Ask to your self before u ask someone


for insertion,just insert like varchar

insert into testxml(1,'<01card CardID="1" CardName="AccountCategory" CardDescription="Account Category"/>')





Hi Visakh,

missing VALUES in insert statement

insert into testxml VALUES (1,'<01card CardID="1" CardName="AccountCategory" CardDescription="Account Category"/>')


Morover even after adding Values Keyword

Msg 102, Level 15, State 1, Line 1
Incorrect syntax near ')'.

It is displaying error message as above

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-23 : 10:33:21
thats because the xml is not well formed. the posted xml is not correct. try a valid xml and it will work.
Go to Top of Page
   

- Advertisement -