Start with SQL Books Online or another book about SQL programming. Read about Stored Procedures, Update and Delete statments, and possibly cursors. Depending on your exact requirement, you may want to read about control-of-flow language in T-SQL. Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.