Tuesday, 13 February 2018

Select, Insert, Update, Delete Using Stored Procedure in SQL Server 2008


Alter PROCEDURE MasterInsertUpdateDelete   
(   
@id INTEGER,   
@first_name VARCHAR(10),   
@last_name VARCHAR(10), 
 @salary DECIMAL(10,2),   
@city VARCHAR(20),   
@StatementType nvarchar(20) = ''   
)   
AS   
BEGIN 

IF @StatementType = 'Insert'   
BEGIN   
insert into employee (id,first_name,last_name,salary,city) values( @id, @first_name, @last_name, @salary, @city)   END   

IF @StatementType = 'Select'   
BEGIN   
select * from employee   
END   

IF @StatementType = 'Update'   
BEGIN   
UPDATE employee SET   
First_name = @first_name, last_name = @last_name, salary = @salary,   
city = @city   
WHERE id = @id   
END   

else IF @StatementType = 'Delete'   
BEGIN   
DELETE FROM employee WHERE id = @id   
END   

end

http://www.c-sharpcorner.com/UploadFile/rohatash/select-insert-update-delete-using-stored-procedure-in-sql/ 

1 comment:

  1. Prediction-based games require users to understand their rules and random outcomes. BDG Win prediction game is worth exploring for beginners who want to learn about gameplay mechanics, platform features, and the importance of responsible participation.

    ReplyDelete