Saturday, 18 June 2016

IF Else Statements In SQL Stored Procedure

6/18/2016 - By Pranav Singh 0

This article will show you how you can user if statement in you sql stored procedure to execute query on the bases of passed parameter.

So here SP with if statement.

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE SP_Demo
@Type int
AS
BEGIN
if(@Type=1)
       Begin
              Select * from DemoTable1
       END
       Else
       Begin
              Select * from DemoTable2
       End
GO

In above I have taken a @Type variable in this user will pass the value and on the bases of the value SP will execute the related query.

Tags:
About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Global Classified : Connectseekers.com
© 2014 aspdotnet-pools.com Designed by Bloggertheme9.
back to top