title: Regarding Dynamic sql construction
body: <p>when we load xml into cursor then we specify column name and their datatype and size. instead of specifying manually how could i make that area dynamic. suppose my tsql as follows</p>
  
  <pre><code>Exec sp_xml_preparedocument @XMLFormat OUTPUT, @DetailXml
  
  -- Create Cursor from XML Table
  
  Declare CurDetailRecord
  Cursor For
  Select productid,unit,rate,qty,amount
  From Openxml (@XMLFormat, '/NewDataSet/PurchaseOrderDetail', 2)
  With
  (
  productid Varchar(10),
  unit Varchar(50),
  rate decimal(18,2),
  qty decimal(18,3),
  amount decimal(18,2)
  )
  </code></pre>
  
  <p>here as a example</p>
  
  <pre><code>productid Varchar(10),
  unit Varchar(50) 
  </code></pre>
  
  <p>etc i am specifying and also specify their data tyoe &amp; size.</p>
  
  <p>so how could i construct this area dynamically and fetch the column name and data type &amp; size dynamically.</p>
  
  <p>please guide me thanks.</p>