Converting XML to Table in SQL Server

Converting XML to Table in SQL Server
Converting XML to Table in SQL Server

Hello everyone. In this article, I will try to give information about converting XML to table in SQL Server.

In SQL Server you may want to convert XML to table in some cases.

You can easily do this by revising the sample code below.

	KullaniciId INT
   ,KullaniciAdi NVARCHAR(50)
   ,Sifre NVARCHAR(50)
SET @xml = '
<row KullaniciId="1" KullaniciAdi="Yavuz" Sifre="1234" />
<row KullaniciId="2" KullaniciAdi="Selim" Sifre="5678" />'

		Tbl.Col.value('@KullaniciId', 'INT')
	   ,Tbl.Col.value('@KullaniciAdi', 'NVARCHAR(50)')
	   ,Tbl.Col.value('@Sifre', 'NVARCHAR(50)')
	FROM @xml.nodes('//row') Tbl (Col)

FROM @TempTablo

When you run the above code, you will see a result similar to the one below.

Converting XML to Table in SQL Server

As you can see, we have converted the XML into a table.

Good luck to everyone in business and life.



Yavuz Selim Kart

I try to explain what I know in software and database. I am still improving myself by doing research on many programming languages. Apart from these, I am also interested in Graphic Design and Wordpress. I also have knowledge about SEO and Social media management. In short, I am a determined person who likes to work hard.

You may also like...

Don`t copy text!