Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
pls some one tell that how to update all records in stored procedure like i have a table called employee. and the column in that table are empid, gender. in gender column the stored data is male and female both. i need to write the stored procedure to update all recoreds where gender=male to replace like gender=female.

basically update female records to male.

Pls help me to solve the problem.
Posted

1 solution

I'm not sure why you need to do this but given you say you want to do this.
You don't necessarily need a stored procedure. The T-SQL to do the update is:

UPDATE employee SET gender ='male' WHERE gender = 'female'

You can create a SP if you want:

SQL
CREATE PROCEDURE UpdateGenders
AS
BEGIN
    UPDATE employee SET gender ='male' WHERE gender = 'female'
    END
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900