Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Need to pipe a variable into a SQL 2012 UPDATE query, or something similar

$
0
0

I wrote a simple update query (all fields arein the same table)to change certain specific field values based on a field called StockCode. What I need to do is run the query for each specific StockCode and thought it would be easy but I have very little skill on the data side of things in SQL. Thequery works as needed.Below is my query:

UPDATE InvMaster
SET ManufactureUom = 'FT',
ConvFactMuM = 1.000000,
ManMulDiv = 'M'
WHERE StockCode = '712-05';

What I need to do is change the StockCode and rerun the query. For example:

UPDATE InvMaster
SET ManufactureUom = 'FT',
ConvFactMuM = 1.000000,
ManMulDiv = 'M'
WHERE StockCode = '712-07'

Since I am only updating certain StockCodes, I need a fairly simple, automatedway to change the StockCode and rerun the query. I found a good bit of infoabout creating temp tables and importing a CSV but it is a bit...


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>