Monday, 11 April 2016

How to Convert HTML Table in SQL Table using TSQL


DECLARE @Xml xml
set @Xml='<tr>
                     <td>Vikas Ahlawat</td>
                     <td>MCA</td>
                     <td>28</td>
                </tr>
                <tr>
                     <td>Ashwani</td>
                     <td>MCA</td>
                     <td>29</td>

                </tr>'

T-SQL QUERY TO GET THE ABOVE HTML TABLE VALUE AS A SQL TABLE

SELECT Name = T.C.value('(./td)[1]','varchar(100)'),
           Education = T.C.value('(./td)[2]','varchar(100)'),
           Age = T.C.value('(./td)[3]','varchar(100)')
FROM @Xml.nodes('(/tr)') as T(C)

Result:


WHAT OTHERS ARE READING/RELATED TO THIS:

0 comments:

Post a Comment

Find job here...