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 |
Sajesh.kumar
Starting Member
3 Posts |
Posted - 2009-02-03 : 04:38:50
|
declare @chkval set @chkval = (select 1 as tag,null as parent,stud_id as [StudentDetails!1!id],fname as [StudentDetails!1!First Name!Element]from student_details StudentDetails for xml explicit)when i am trying to execute it gives incorrect syntax near xmlCan any body help me out to figure out the problem.Sajesh Kumar |
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-02-03 : 04:50:49
|
declare the datatype for @chkval |
|
|
AvanthaSiriwardana
Yak Posting Veteran
78 Posts |
Posted - 2009-02-03 : 04:51:38
|
use FOR XML RAWAvantha SiriwardanaBeware of bugs in the above code; I have only proved it correct, not tried it. (Donald Knuth) |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-02-03 : 04:54:23
|
its working i have taken some sample data and works in sql2005 and sql query analyzer alsodeclare @temp table (Id int, FirstName varchar(32))insert into @tempselect 1, 'FirstName1' union allselect 2, 'FirstName2' union allselect 3, 'FirstName3' union allselect 4, 'FirstName4' union allselect 5, 'FirstName4' union allselect 6, 'FirstName4' union allselect 7, 'FirstName4'declare @chkval varchar(32)select @chkval = (select 1 as tag,null as parent,id as [StudentDetails!1!id],FirstName as [StudentDetails!1!First Name!Element]from @temp StudentDetails for xml explicit)select @chkval |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-03 : 10:16:57
|
quote: Originally posted by bklr its working i have taken some sample data and works in sql2005 and sql query analyzer alsodeclare @temp table (Id int, FirstName varchar(32))insert into @tempselect 1, 'FirstName1' union allselect 2, 'FirstName2' union allselect 3, 'FirstName3' union allselect 4, 'FirstName4' union allselect 5, 'FirstName4' union allselect 6, 'FirstName4' union allselect 7, 'FirstName4'declare @chkval varchar(32)select @chkval = (select 1 as tag,null as parent,id as [StudentDetails!1!id],FirstName as [StudentDetails!1!First Name!Element]from @temp StudentDetails for xml explicit)select @chkval
did you check in sql 2000?b/w this is sql 2000 forum so i guess op is using sql 2000 |
|
|
|
|
|
|
|