Skip to main content

SQLSERVER Functions- Coalesce()

SQL Server  built-in functions

Coalesce()

It is A function Is Very Much Useful at Run time When We Have Multi Value Attribute in a Table.
If U Consider below facts placed in a employee table With Id, Name, ph_no, Alt_no, Office no.

id
Name
Ph_ no
Alt_ no
Office no
101
Albert
999999
456453
321333
102
khan
null
null
123455
103
victor
112121
null
null
104
lovely
null
null
1897321

Above Employee table may have single value are three values if it have single value then it fill null  values with remaining attributes
When We Retrieve The Number from employee table That Number Should Not be Null value To get not null value from employee table We Use Coalesce() Function It Returns First Encountered Not Null Value  from employee table

select id , name ,coalesce(Ph_no,Alt_no,Office_no) as contact number from employee
 it returns
id
Name
Contact number
101
Albert
999999
102
khan
123455
103
victor
112121
104
lovely
1897321


Thank you

Comments

Popular posts from this blog

Shortcut keys inMSDOTNET 2015

when ever we want work with MS.net we have to learn about some keys which can help to improve our work force in development area .i  got some shortcut key in msdn ,You can view all of the keyboard shortcuts for Visual Web Developer. we can create our own shortcuts by doing the following:  on the  Tools  -->  Options ; it will open dialog box  of the Options ,  select  Environment  and then  Keyboard . we have to select the  Show all settings  check box in order to view the  Keyboard  setting. Shortcut Description CTRL+B Switches the selected text between bold and normal. CTRL+I Switches the font style of the selected text between italic and roman. CTRL+U Switches the font style of the selected text between underline and roman. CTRL+SHIFT+L Displays the  Bookmark  dialog box. CTRL+L When text is selected, displays the  Hyperlink  dialog box. ...

connection pooling

Explain about Connection Pooling? Connection pooling is a concept which deals with database connection. A Connection Pool maintain last database connection active state when connection is ideal. Whenever you want to make a transaction with database once again you have to open connection when it is ideal, instead of that connection pooling will maintain open and reusable connections. A Connection Pool is released from the buffer or memory when the last connection to the database is closed. By default Connection Pooling turned on in ado.net; whenever you want to change it off, you have to specify Pooling = false in the connection string . We can specify limit to connection pooling by default the maximum limit is 100. You will specify in connection string. It will improves the performance and scalability of the application It is managed by a program in ado.net that we called as Pool Manager. This program will ma...

Fundamentals of Design Patterns

Fundamentals of Design Patterns   hi developers and programmers  in this post i am going to share Videos where i learned fundamentals of design patterns   it is great visual you can enjoy this  have a nice day