C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |



My Profile

Gifts

Active Members
TodayLast 7 Days more...







Using If conditions inside stored procedures


Posted Date: 31 Jul 2008    Resource Type: Articles    Category: Databases

Posted By: Ilyas       Member Level: Silver
Rating:     Points: 4



This code sample illustrates the uses of if-conditions in a stored procedure in databases.


create PROC [dbo].[usp_category_sel]
(
@category_name varchar(200)=null,
@cat_id int=null
)

AS
BEGIN
if @category_name is not null
begin
SELECT cat_id,category_name,status FROM category where category_name=@category_name
end

else if((@cat_id is not null)and (status is not null))
begin
SELECT cat_id,category_name,status FROM category WHERE cat_id=@cat_id
end

else
BEGIN
SELECT cat_id,category_name,status FROM category where status='true'
END
END




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Using If conditions inside stored procedures  .  Using conditions in stored procedures  .  If statements in stored procedures  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Set Operations in SQL Server
Previous Resource: Bulk Operations in SQL Server
Return to Discussion Resource Index
Post New Resource
Category: Databases


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

it outsourcing

Contact Us    Privacy Policy    Terms Of Use