Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Select Statement with an "In-Line" Condition

$
0
0

I will try and keep this as simple and straight forward as possible.

I want to generate a Select statement that will get me all my Products and their weight from my SQL database.  I would like to calculate and Return a TONS (Weight * 2000) value. 

I might have 100,000 or so.  What I currently do is run a statement similar to this:
SELECT Prod_ID, Weight, CAST('' as nvarchar(250)) AS Weight_Tons FROM PRODUCTS

Then I take my results and and make a disconnected RS then process each record and fill my "Weight_Tons" field.

The process doesn't seem very efficient.  I do have a Unit of Measure(UOM) field. So In my SELECT statement can I reference that and do my calculation as part of my initial SQL statement?

Thank you for any suggestions.


Viewing all articles
Browse latest Browse all 23857

Trending Articles



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