Increase each value by 15% in MSSQL

I have an Emp table with the columns Name and Salary respectively. I want to increase salary by 15% in MSSQL .

The following query is for one update only, and I still cannot execute it ...

UPDATE Emp SET Salary = '(@Salary / 100) * 15 + @salary' WHERE Name='Zangiv' 

I need one query operator to update multiple rows at once.

Thank you in advance

+4
source share
7 answers
 UPDATE Emp SET salary = salary * 1.15 WHERE Name = 'Zangiv' 
+6
source

Given your stated requirement:

I want to increase salary by 15% in MSSQL

The next request will increase ALL wages by 15%.

 UPDATE Emp SET Salary = Salary * 1.15 

If you really do not want to update ALL rows in your table, use the WHERE if necessary.

+3
source

Depending on whether you have "multiple lines named Zangiv " or all lines:

 UPDATE dbo.Emp SET Salary = Salary * 1.15 --WHERE Name = 'Zangiv'; 
+3
source
 UPDATE Emp SET Salary = Salary * 1.15; 

increase salaries for all employees by 15%;

+2
source

SQL 2008 onwards

 UPDATE Emp SET Salary *= 1.15 

otherwise

 UPDATE Emp SET Salary = Salary * 1.15 
+2
source

Request to update a single specific row

 UPDATE Emp SET Salary = Salary*15/100 WHERE Name = 'Zangiv' 

Request to update all rows

 UPDATE Emp SET Salary = Salary*15/100 
+1
source

ive did the same, but did not increase ive, reduced the value by 20%, which looks something like this.

SET Cost = Cost - (cost * 0.20) where SerialNumber = 'mmmmmm'

-1
source

Source: https://habr.com/ru/post/1433636/


All Articles