Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2005 > SQL Server 2005
|
SQL Server 2005 General discussion of SQL Server *2005* version only.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 16th, 2008, 03:25 AM
Authorized User
 
Join Date: Sep 2006
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Convert NULL to zero SQL 2005

Hello,

I do most of my programming via MS-Access/VBA SQL2000.

I've migrated to SQL 2005 and would like to utilise SQL for more of my calc work.
I run into problems when trying to SUM values via a View, where some values = NULL.
In Access i'd write an IIF expression in a query to convert NULL values to 0 for calculation purposes.

Can somebody please advise how to perform this via SQL 2005.

Thankyou,

Dave
 
Old September 16th, 2008, 01:32 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

You'll love this:

    ISNULL( fieldname, 0 )

Yep. Really.

Does the same thing as

    IIF( fieldname IS NULL, 0, fieldname )

in Access.
 
Old September 16th, 2008, 10:43 PM
Authorized User
 
Join Date: Sep 2006
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very very much.

Dave





Similar Threads
Thread Thread Starter Forum Replies Last Post
reg conn to sql server 2005 from vb.net 2005.. veda SQL Server 2005 2 July 1st, 2008 12:16 AM
vb 2003 to 2005 convert gone wrong mr_kane General .NET 2 August 5th, 2007 04:35 PM
convert a SQL Statement from MS Access to a SQL Corey Access 6 March 28th, 2007 12:33 PM
Convert NULL to String for Concatenation? Ron Howerton SQL Language 5 September 23rd, 2006 05:54 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.