Solved

isnull use in sql condition

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Record open by another user 6 73
Get row count of current SQL query 8 64
My Query is not giving correct result. Please help 5 55
Sql Server group by 10 49
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

756 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