Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 null issue

Author  Topic 

helixpoint
Constraint Violating Yak Guru

291 Posts

Posted - 2009-03-22 : 09:39:56
If there are no records, I want to return a 1, not a null.This does not work

SELECT CASE WHEN MAX(priority) IS NULL THEN @nextPriority = 1 ELSE @nextPriority = MAX(priority) END
FROM movies

Dave
Helixpoint Web Development
http://www.helixpoint.com

helixpoint
Constraint Violating Yak Guru

291 Posts

Posted - 2009-03-22 : 10:04:13
got it
SELECT @nextPriority = CASE WHEN MAX(priority) IS NULL THEN 1 ELSE MAX(priority)+1 END
FROM helixpo_CLASSICDVDS.movies

Dave
Helixpoint Web Development
http://www.helixpoint.com
Go to Top of Page

Nageswar9
Aged Yak Warrior

600 Posts

Posted - 2009-03-22 : 10:05:59
select isnull(max(priority),0)+1 from urtable
Go to Top of Page
   

- Advertisement -