I have One table "tblData" with One column "strData".
I am inserting XML string in this table.
I want to read this xml and insert record into another table.
When i write bellow code it is working fine,
Declare @xmlRec xml
Select TOP 1 @xmlRec = strData FROM tblData
SELECT
tmpTable.col.query ('FName').value('.','varchar(50)') AS FName,
tmpTable.col.query ('LName').value('.','varchar(50)') AS LName,
tmpTable.col.query ('Mobile').value('.','varchar(50)') AS Mobile
FROM @xmlRec.nodes('data/data') AS tmpTable(col)
But I want to create select statement Dynamically. Like I am reading column name from another table and creating dynamic select statement.
When i execute that statement it will not work because "@xmlRec.nodes" is giving error.
I want to create dynamic Query and insert selected record into another table.
Please help....