lundi 4 juillet 2016

How to split a string in sql server using stored procedure and insert the data to table

<pre>update d 
  set d.Price = null 
from dbo.SalDocumentDetail d 
left join dbo.StkWarehouse w on w.WarehouseID = d.WarehouseID 
where DocumentID=" + 1 + " 
and DocumentTypeID=" + 2 + " 
and FiscalYear= " + 2016 + " 
and isnull(isPrescription,0) <>1 
and w.POSType is null 
and ProductName BETWEEN ''C' 'AND' 'M''
and Country LIKE ''%land%'''</pre>

Actually this string is only a sample one my original string is very large . i am not getting a point that if i break this string than how many variables i have to make to capture the data also after splitting the string i want that to be inserted into data table containing columns as Felid and Value?

I want my result like :
<pre>
Felid                         Value
 DocumentID=                    1 
 DocumentTypeID=                2 
 FiscalYear=                   2016 
 isnull(isPrescription,0) <>=     1 
 w.POSType is=                 null 
 ProductName=                   C
 ProductName=                   M 
 Country=                       land 
</pre>

Aucun commentaire:

Enregistrer un commentaire