Created
February 2, 2020 18:02
-
-
Save tqaw19/d51f7b4d0b97f3d3bfe904b33fa40915 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- ================================================ | |
-- Template generated from Template Explorer using: | |
-- Create Procedure (New Menu).SQL | |
-- | |
-- Use the Specify Values for Template Parameters | |
-- command (Ctrl-Shift-M) to fill in the parameter | |
-- values below. | |
-- | |
-- This block of comments will not be included in | |
-- the definition of the procedure. | |
-- ================================================ | |
SET ANSI_NULLS ON | |
GO | |
SET QUOTED_IDENTIFIER ON | |
GO | |
-- ============================================= | |
-- Author: <Author,,Name> | |
-- Create date: <Create Date,,> | |
-- Description: <Description,,> | |
-- ============================================= | |
CREATE PROCEDURE crudemp | |
@Id int = null, | |
@Empname nvarchar(150) = null, | |
@Email nvarchar(150) = null, | |
@Salary int, | |
@CrudOption nvarchar(50) = null | |
AS | |
BEGIN | |
-- SET NOCOUNT ON added to prevent extra result sets from | |
-- interfering with SELECT statements. | |
SET NOCOUNT ON; | |
if(@CrudOption = 'Select') | |
begin | |
select * from Emptable | |
end | |
if(@CrudOption = 'Details') | |
begin | |
select * from Emptable where Empid = @Id | |
end | |
if(@CrudOption = 'Insert') | |
begin | |
insert into Emptable values (@Empname, @Email, @Salary) | |
end | |
if(@CrudOption = 'Update') | |
begin | |
Update Emptable set Empname=@Empname, Email=@Email, Salary = @Salary where Empid = @Id | |
end | |
if(@CrudOption = 'Delete') | |
begin | |
Delete from Emptable where Empid = @Id | |
end | |
END | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment