Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Using UPDATE

Author  Topic 

BadFish
Starting Member

4 Posts

Posted - 2009-09-06 : 19:40:59
Hello,
I am currently working on a project and am having a few problems.
I am trying to increase the salary of employees in my database by 5%

I have written the following queries:


SELECT *
FROM Employee
WHERE EEO1Class LIKE 'Sales Worker'



This selects the Employees based on job classification and it runs just fine. Next I want to increase the Salary rate by 5% for those employees only. So I wrote the following:



UPDATE Employee
SET Salary = 'Salary * 5%'
WHERE EEO1Class='Sales Worker'


However when I run this I get the following error:


Msg 235, Level 16, State 0, Line 2
Cannot convert a char value to money. The char value has incorrect syntax.


Anyone have any ideas, hints, tips?



UPDATE Employee
SET Salary = 'Salary * 5%'
WHERE EEO1Class='Sales Worker'

BadFish
Starting Member

4 Posts

Posted - 2009-09-06 : 19:46:22
Sorry
I am running MS SQL 2008 and the Salary field is set to money.
Go to Top of Page

andrewcw
Posting Yak Master

133 Posts

Posted - 2009-09-06 : 19:49:49
I may not have an idea but have you tried simply multiplying by 1.05 ...??? % could be understood differently...

andrewcw
Go to Top of Page

BadFish
Starting Member

4 Posts

Posted - 2009-09-06 : 20:21:21
I went ahead and tried that, I wrote this and got the same error:


UPDATE Employee
SET Salary = 'Salary * 0.05'
WHERE EEO1Class='Sales Worker'


I double checked the Salary Field and it is set to

Salary money NOT NULL,
Go to Top of Page

andrewcw
Posting Yak Master

133 Posts

Posted - 2009-09-06 : 21:48:18
Normally I would expect to see values that are strings and dates set off with single quotes. What error do you get without the quotes { its a numeric value },

andrewcw
Go to Top of Page

BadFish
Starting Member

4 Posts

Posted - 2009-09-06 : 23:23:52
Thanks, that seemed to be the problem, removing them fixed the error and allowed it to work.

thanks,
Go to Top of Page
   

- Advertisement -