Solved

isnull use in sql condition

Posted on 2011-09-12
2
281 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
execute a MS SQL script as a schedule SQL job 72 155
Set the max value for a column 7 43
tempdb log keep growing 7 56
Are triggers slow? 7 29
When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
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…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 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