i have one employee tabel with 4 coloums
emp name emp id employee salary tax
john 001 30k
smith 112 15k
joe 113 45k
i have to fill tax coloum =25% when salary >=30k otherwise just --
can any one tell me the query ?

Recommended Answers

All 2 Replies

Do you mean that your data actually contains the charcter 'K' in the salary value ?
(that would be ugly)
Assuming that it is true:

UPDATE dbo.Employee
SET TAX = ( 1.25 * Convert(int,substring(Salary,1,len(Salary)-1) )
WHERE Salary > '30K'

**free handed, so perform some tests on a temp table before using it on a real system.

// Jerry

UPDATE dbo.Employee
SET TAX = ( 1.25 * (Convert(int,substring(Salary,1,len(Salary)-1) * 1000 ))
WHERE Salary > '30K' OR len(Salary > 3)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.