| | |
SQL Server Question...
Please support our ASP.NET advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Hi,
I have one question related to SQL Server. But there is not forum on this. so here is my Question.
While accessing multiple columns value in a single alias column we right query as follows.
Am I right ?
But the question is when one of values from FNAME, MNAME, LNAME if comes NULL then my NAME filed will be NULL.
How to avoid this?? Any one have solution for this.
Note : I am using this Query for Creating VIEW.
Thanks. Have a Lovely Time.
I have one question related to SQL Server. But there is not forum on this. so here is my Question.
While accessing multiple columns value in a single alias column we right query as follows.
ASP.NET Syntax (Toggle Plain Text)
Select FNAME +' '+ MNAME +' '+ LNAME as NAME from Cust_Master
Am I right ?
But the question is when one of values from FNAME, MNAME, LNAME if comes NULL then my NAME filed will be NULL.
How to avoid this?? Any one have solution for this.
Note : I am using this Query for Creating VIEW.
Thanks. Have a Lovely Time.
Accept Challenges and Enjoy Coding... :)
•
•
Join Date: Sep 2007
Posts: 1,080
Reputation:
Solved Threads: 68
Scratch that! Use a predefined function called COALESCE. It's a life saver. Format:
COALESCE(columnname, 'valueifnull')
COALESCE(columnname, 'valueifnull')
ASP.NET Syntax (Toggle Plain Text)
Select COALESCE(FNAME, '') +' '+ COALESCE(MNAME, '') +' '+ COALESCE(LNAME, '') as NAME from Cust_Master
•
•
Join Date: Sep 2007
Posts: 1,080
Reputation:
Solved Threads: 68
This way if middle nam eis null or something, it will show:
FNAME LNAME
or MNAME LNAME
or FNAME LNAME, etc.
Oh and there is a forum for MS SQL:
http://www.daniweb.com/forums/forum127.html
FNAME LNAME
or MNAME LNAME
or FNAME LNAME, etc.
Oh and there is a forum for MS SQL:
http://www.daniweb.com/forums/forum127.html
Last edited by SheSaidImaPregy; Mar 5th, 2008 at 10:17 am.
•
•
Join Date: Jan 2008
Posts: 2,052
Reputation:
Solved Threads: 123
•
•
•
•
Scratch that! Use a predefined function called COALESCE. It's a life saver. Format:
COALESCE(columnname, 'valueifnull')
ASP.NET Syntax (Toggle Plain Text)
Select COALESCE(FNAME, '') +' '+ COALESCE(MNAME, '') +' '+ COALESCE(LNAME, '') as NAME from Cust_Master
Due to lack of freedom of speech, i no longer post on this website.
![]() |
Similar Threads
- Finding the nth row (SQL)...debative question (MS SQL)
- MySQL vs. SQL Server (PHP)
- SQL Server newbi... how to get started?? (MS SQL)
- Error in SQL Server 2005 (MS SQL)
- C# failing to drop stored procedure from SQL Server using SMO (C#)
- Enable only one user to edit a row in SQL server database using C#, asp.net win apps (ASP.NET)
- Need you suggestion for MS-SQL Server course (IT Professionals' Lounge)
- How to connect ASP with sql server ? (Community Introductions)
- SQL Server vs MYSQL vs MSQL (i'm stopping now) (MS SQL)
Other Threads in the ASP.NET Forum
- Previous Thread: how to make output cached page expire(refresh) before its duration completes
- Next Thread: Session in app_code
Views: 683 | Replies: 7
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 3.5 ajax appliances application asp asp.net beginner box browser businesslogiclayer button c# cac chat checkbox child class compatible complex content contenttype control countryselector courier database datagrid datagridview datalist deployment development dgv dialog dropdown dropdownmenu dynamic dynamically edit embeddingactivexcontrol feedback fileuploader fill findcontrol flash flv folder form gridview gudi identity iis image javascript languages list maps menu mobile mssql nameisnotdeclared novell opera order problem profile ratings redirect refer registration relationaldatabases response.redirect rows search security select serializesmo.table sessionvariables silverlight smoobjects software sql ssl tracking treeview typeof validatedate validation vb vb.net vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopment wizard xsl







