I am passing table name and XML string to Sql Server SP. I want to insert records to corresponding table. how to read the column name dynamically?
Example : 1===========Declare @TableName = 'Table1'Declare @xml1 xmlset @xml1 = '<Root> <Nodes> <Id>01</Id> <Name>Mike</Name> </Nodes></Root>'
insert into @TableName ( --column names from @xml ) values ( --select ID from @xml, --select Name from @xml)
Example : 2===========
Declare @TableName = 'Table2'Declare @xml2 xmlset @xml2 = '<Root> <Nodes> <EmpId>05</EmpId> <EmpName>Andrew</EmpName> </Nodes></Root>'