Procedure: Setting a New Minimum Salary


 

Script

This procedure is used to specify a new minimum salary for employees. It examines all records and changes only the salary of those that are below a new value. This new value is passed as argument to the procedure:

-- creating the store procedure
IF EXISTS (SELECT name 
	   FROM   sysobjects 
	   WHERE  name = N'SetNewMinSalary' 
	   AND 	  type = 'P')
    DROP PROCEDURE SetNewMinSalary
GO

CREATE PROCEDURE SetNewMinSalary 
	@NewSalary SmallMoney
AS
	UPDATE Employees
         SET Salary = @NewSalary
	FROM Employees WHERE Salary < @NewSalary
GO
 

Home Copyright © 2004-2010 FunctionX, Inc.