Solved

isnull use in sql condition

Posted on 2011-09-12
2
274 Views
Last Modified: 2012-05-12
hello: i'm trying to get the right syntax for...

DECLARE @sessionId int

SELECT @sessionId = 1 + CONVERT(float,ISNULL(MAX(SESSIONID) FROM CONTROL.dbo.tblProgressHx,0))

PRINT @sessionID


thanks!
0
Comment
Question by:ironpen45
2 Comments
 
LVL 5

Accepted Solution

by:
DavidMorrison earned 500 total points
ID: 36523296
try this

select 1 + cast(ISNULL(MAX(SesionID), 0) as float) as SessionNew
from CONTROL.dbo.tblProgressHx

if you really want it in a variable then

DECLARE @sessionId int

select @SessionID = 1 + cast(ISNULL(MAX(SesionID), 0) as float) as SessionNew
from CONTROL.dbo.tblProgressHx

PRINT @sessionID


Thanks

Dave
0
 

Author Closing Comment

by:ironpen45
ID: 36523406
works like a charm. thanks!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now