Solved

isnull use in sql condition

Posted on 2011-09-12
2
277 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

770 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