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.
| Author |
Topic |
|
rsegecin
Yak Posting Veteran
82 Posts |
Posted - 2007-07-02 : 15:58:37
|
| hi guys, I'm using SQLServer 2005 and I was wondering how I check if some variable is null or not? I tryied to do as the code show but it doesn't work:declare @number intset @number = (select number from numbers where number_id = 1)if (@number = null) begin set @number = 12 endThank you very much |
|
|
sshelper
Posting Yak Master
216 Posts |
Posted - 2007-07-02 : 15:59:50
|
| You have to use the IS NULL condition and not the = sign:if @Number IS NULL SET @Number = 12SQL Server Helperhttp://www.sql-server-helper.com |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-07-02 : 16:00:33
|
| select @number = number from numbers where number_id = 1set @number = isnull(@number, 12)Peter LarssonHelsingborg, Sweden |
 |
|
|
rsegecin
Yak Posting Veteran
82 Posts |
Posted - 2007-07-02 : 16:01:13
|
| thank you both =D |
 |
|
|
|
|
|