This is one of the typical SQL Server interview questions and also the favorable question of the interviewers. The interviewers ask this question to check your skills on converting the table data in to XML format but many of your developer friends fails to answer this question.
Below is the syntax of how to convert table data in to XML format.
Syntax: - Select * From [TableName] For XML Path
So, let demonstrate a sweet and simple example to see how exactly we can convert
table data in to XML format using a simple query.
Assume that we have the following Customer’s table with their respective data
types and data.
Now, let’s create a simple query to obtain your required result.
Query: -
Select * from Customer For XML Path
As soon as you execute the above query you will see the result like below
diagram.
Now, when you click on the link you will see the XML result like below diagram.
In the above diagram you can clearly see that now your table data has been
successfully converted in to the XML format.
See the following video on Basics SQL Server - Query Plan, Logical/Physical
operators as follows: -
Get more materials on SQL Server interview questions
Regards,
See more stuffs on author’s blog for SQL Server interview questions
Below is the syntax of how to convert table data in to XML format.
Syntax: - Select * From [TableName] For XML Path
So, let demonstrate a sweet and simple example to see how exactly we can convert
table data in to XML format using a simple query.
Assume that we have the following Customer’s table with their respective data
types and data.
Now, let’s create a simple query to obtain your required result.
Query: -
Select * from Customer For XML Path
As soon as you execute the above query you will see the result like below
diagram.
Now, when you click on the link you will see the XML result like below diagram.
In the above diagram you can clearly see that now your table data has been
successfully converted in to the XML format.
See the following video on Basics SQL Server - Query Plan, Logical/Physical
operators as follows: -
Get more materials on SQL Server interview questions
Regards,
See more stuffs on author’s blog for SQL Server interview questions
No comments:
Post a Comment