Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

For Loop for an update Statement

$
0
0

Hi All, 

I am trying to write a For loop for an update statement. My Update query works fine. The variable is the productname. 

UPDATE
  [LicenseHarvesting].[dbo].[LicenseCosting]
SET
[LicenseCosting].RecoveredCost = (SELECT count(*)
FROM [LicenseHarvesting].[dbo].[LicenseHarvestingStatusTable]
    where Productname = 'ABC' and [LicenseHarvestingStatusTable].ActionbySCO = 'Delete')*(Select [LicenseCosting].[LicenseCost] from [LicenseHarvesting].[dbo].[LicenseCosting] where [LicenseCosting].[ProductName] = 'ABC')
    where   [LicenseCosting].[productName] = 'ABC';

===========================================

  This will give all the product name from the table.    

Begin
  for i in (select [LicenseCosting].[ProductName])

  Loop
My Update Query ---
 
  end loop;
end;

Can anyone help me in this pls. 


Priyabrata


Viewing all articles
Browse latest Browse all 7129

Trending Articles



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