I want to do something like the example below
ColumnAVal = Select ColumnA from TableA where....
ColumnBVal = Select ColumnB from TableA where....
Select * from TableB where ColumnC = (value from ColumnA)
Select * from TableC where ColumnD = (value from ColumnB)
I have to get the values from TableA query which has one hefty where clause. And I have to get about 20 different columns from TableA. So, above example won't be a good idea. I am trying to find a better way to save these values, that doesn't require me to use same where clause 20 times.
Basically idea is to get the 20 or so columns from the TableA and save those as variables for later use. That way I can create just one query to save the column values instead of calling it twenty times.
E.g.
@QuantityAvailable = SELECT TOP 1 WLPS_Qty_Available FROM
TBL_Warehouse_Location_Parts_Spec, TBL_Location_Master,
TBL_Warehouse_Master WHERE WLPS_Parts_Spec_ID = @PartSpecID AND WLPS_Part_Type_ID IN ( 0, @PartTypeID ) AND WLPS_Active_Flag = 'Y' AND ( WLPS_Location_ID = @LocationID )
I have to run the same query again and again 20 times. And I would prefer I don't have to, to save some processing.
whereclauses. Also, tag your question with the database you are using . . . sample data and desired results are helpful. And what doescolumnBhave to do with anything?