Syntax for inserting value in stored procedure in sql server

In this article, I will how to create a store procedure for insert a value in store procedure. Stored Procedure in SQL Server can be defined as the set of logical group of SQL statements which are grouped to perform a specific task. There are many benefits of using a stored procedure. The main benefit of using a stored procedure is that it increases the performance of the database.

For More : Syntax for update stored procedure in SQLServer , Stored Procedure in SQL SERVER , Difference between Function and Stored Procedure 




First step :- creating table

Syntex for creating table:-


CREATE
TABLE [dbo].[ reg](
          [UserId] [int] IDENTITY(1,1) NOT NULL,
          [Username] [nvarchar](20) NOT NULL,
          [firstname] [nvarchar](max) NULL,
          [lastname] [nvarchar](max) NULL,
          [gender] [nvarchar](max) NULL,
          [dob] [nvarchar](max) NULL,
          [email] [nvarchar](max) NULL,
          [password] [nvarchar](max) NULL,
          [nationality] [nvarchar](max) NULL,
         
 CONSTRAINT [PK_registration] PRIMARY KEY CLUSTERED
(
          [UserId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO


Second Step:- insert value into  stored procedure

Syntex for inserting value in  stored procedure


CREATE PROCEDURE [dbo].[Insert_Userinfo]
          @username NVARCHAR(20),
          @firstname nvarchar(max),
          @lastname nvarchar(max),
          @gender nvarchar(max),
          @dob nvarchar(max),
          @email nvarchar(max),
          @password nvarchar(max),
          @currentcity nvarchar(max),
          @nationality nvarchar(max)
         
AS
BEGIN


INSERT
INTO [reg]
                                (
                                [Username],
          [firstname],
          [lastname],
          [gender],
          [dob],
          [email],
          [password],
          [nationality],
         
         
                   VALUES
                                (@username,
                                @firstname,
                                @lastname,
                                @gender,
                                @dob,
                                @email,
                                @password,
                                @nationality
                              
                               
END

GO

Syntax for inserting value in stored procedure in sql server Syntax for inserting value in stored procedure in sql server Reviewed by NEERAJ SRIVASTAVA on 2:12:00 PM Rating: 5

No comments:

Powered by Blogger.