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
 SQL Server Administration (2005)
 Generate XML of a already created table

Author  Topic 

Progress2007
Starting Member

17 Posts

Posted - 2008-08-25 : 08:03:57
Hello
I am a newbie for SQLServer 2005. Is there any inbuild functionality exist so that i could able to extract the XML of a table .

If such thing exist in this table then please let me know how to do this.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-25 : 08:04:51
XML of a table? do you mean xml of data? Then have a look at FOR XML in books online.
Go to Top of Page

Progress2007
Starting Member

17 Posts

Posted - 2008-08-25 : 08:06:42
Thnx for ur response. I just want to know that as we can generate script of a database or table, can we do the same thing, means can we generate XML format of a table inside SQL Server 2005
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-08-25 : 08:13:51
select * from table for xml auto

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Progress2007
Starting Member

17 Posts

Posted - 2008-08-25 : 08:21:18
Thnx again for ur response......but tell me one more thing how to get the schema of a table in XML format
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-25 : 08:26:39
quote:
Originally posted by Progress2007

Thnx again for ur response......but tell me one more thing how to get the schema of a table in XML format


select * FROm INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='YourTableName' FOR XML AUTO
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-08-25 : 09:09:54
SELECT * FROM YourTableName FOR XML AUTO, ELEMENTS, XMLSCHEMA('YourTableName')


_______________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.0 out!
Go to Top of Page
   

- Advertisement -