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 2008 Forums
 Transact-SQL (2008)
 How to deal with empty select value

Author  Topic 

misk
Starting Member

2 Posts

Posted - 2011-06-06 : 02:34:06
Hello,
I have problem when the select return nothing(no data to select)
Find in below script if there is no data to return the "@ActionType" will assigned to nothing. and the IF statement will not work correctly.
Any help please.

DECLARE @ActionType INT

SELECT TOP 1 @ActionType = ActionType FROM ...

IF @ActionType != 1
BEGIN
...
END

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-06-06 : 03:15:39
[code]
IF @ActionType != 1 OR @ActionType IS NULL
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

misk
Starting Member

2 Posts

Posted - 2011-06-06 : 04:06:17
Thanks khtan
Go to Top of Page
   

- Advertisement -