Retrieve table structure with OPENXML
-
when we use OPENXML then we have to mention table structure like below one. DECLARE @xml_text VARCHAR(4000), @i INT /* put xml structure here */ EXEC sp_xml_preparedocument @i OUTPUT, @xml_text SELECT au_id AS author_id, au_lname AS last_name, au_fname AS first_name, a.title_id, title, royaltyper AS royalty FROM OPENXML(@i, '/root/authors/titles', 1) WITH ( au_id VARCHAR(11), au_lname VARCHAR(20) '../@au_lname', au_fname VARCHAR(30) '../@au_fname', title_id VARCHAR(15), royaltyper INT) a INNER JOIN titles b ON a.title_id = b.title_id WITH ( au_id VARCHAR(11), au_lname VARCHAR(20) '../@au_lname', au_fname VARCHAR(30) '../@au_fname', title_id VARCHAR(15), royaltyper INT ) suppose if i dont want to mention the table structure manually or hard coded rather dynamically fetch table structure,datatype and length then how could i proceed. please help me with sample code. thanks in advance
tbhattacharjee