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


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




How to use COALESCE() in role


Posted Date: 31 May 2008    Resource Type: Code Snippets    Category: SQL

Posted By: Kumar Velu       Member Level: Diamond
Rating:     Points: 10




lets know what is COALESCE():it accepts a series of values and a value to use in the event that all items in the list are null; then, it returns the first not-null value. This tip describes two creative uses of the COALESCE() function in SQL Server.

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
alter procedure [searchcandidate]
(@Cand_Fname varchar(100),
@Cand_Dob datetime,
@Skills_Id int,
@skills_other varchar(100)
)
as
begin

select c.Cand_Id,c.Cand_Fname,c.Cand_Dob ,c.Cand_Mob,s.Skills,c.Skill_other from can_infotbl c,Can_skilltbl s
where
c.Cand_Fname like coalesce(@Cand_Fname+'%',c.Cand_Fname) and
c.Cand_Dob = coalesce(@Cand_Dob ,c.Cand_Dob) and
c.Skills_Id = coalesce(@Skills_Id,c.Skills_Id) and
c.Skill_other like coalesce(@skills_other+'%',Skill_other)and
c.Skills_Id=s.Skills_Id


end

exec searchcandidate 'kumar',null,null,null




Responses

Author: RajaSekaran R    03 Jun 2008Member Level: Gold   Points : 0
Good Example...


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

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: How to insert single quote into a column in SQL
Previous Resource: Query to return date only field
Return to Discussion Resource Index
Post New Resource
Category: SQL


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

UK Conference calling Company

Contact Us    Privacy Policy    Terms Of Use