.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> SQL Query >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Store Procedure for Beginners

Posted By:Narayanan       Posted Date: July 14, 2011    Points: 40    Category: SQL Query    URL: http://www.dotnetspark.com  

Database is a important thing in the Software Development. I think, without database, we can't do the Software .So it is a Primary one. So every Program should know the Database Concept, Structures and Usages.
 

Store Procedure (SP):

     The following Points are the Store Procedures Definition and usages:

          1. Group of T-SQL statements compiled into a single execution plan.

          2. Store and Retrieve information from Database.

          3. T-SQL task has executed within the Application

          4. Increase Performance

          5. Storing a code inside in the SQL -Server

Create a Store Procedure

1. Select Query

Create Procedure SP_userlogin

As

Select username, password from tbl_Login

Run this Query.

2. Insert Query

Create Procedure SP_Insertuserlogin

@userid varchar (20),

@username varchar (50),

@password varchar (50)

As

Insert into tbl_ Login (userid, username, password) values (@userid, @username,@ password)

3. Update Query

Create Procedure SP_Updateuserlogin

@userid varchar (20),

@username varchar (50),

@password varchar (50)

As

Update tbl_Login set username=@username, password=@password where userid=@userid

4. Delete Query

Create Procedure SP_Deleteuserlogin

@userid varchar (20),

As

Delete from tbl_Login where userid=@userid

 

Search the Store Procedure in the SQL SERVER

SP_HELPTEXT SP_Name

For Ex:

SP_Helptext SP_userlogin

  Select the Line and Press F5.

 You view the Store Procedure like this

Create Procedure SP_userlogin

As

Select username, password from tbl_Login

 If you want to Modify in your store procedure:

Alter Procedure SP_userlogin

As

Select distinct username, password from tbl_Login



     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend