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 2005 Forums
 Transact-SQL (2005)
 assign a Null value

Author  Topic 

agarwasa2008
Posting Yak Master

109 Posts

Posted - 2009-12-18 : 16:24:57
Hi

I have @SomeColName. If the value is '' ie empty string then replace it with NULL. Therefore I wish to assign a null if it does not contain a value. How can I do that.

Stored Prodecure


@col1,
@col2,
@col3

AS
Begin

insert into table1
(col1, col2, col3)
select @col1, @col2, @col3;

End

SA

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-12-18 : 16:33:59
[code]select @SomeColName = nullif(@SomeColName,'')[/code]
Go to Top of Page

agarwasa2008
Posting Yak Master

109 Posts

Posted - 2009-12-18 : 16:49:54
I get the following error:

'ifnull' is not a recognized built-in function name.


SA
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-12-18 : 16:53:34
quote:
Originally posted by agarwasa2008

I get the following error:

'ifnull' is not a recognized built-in function name.


SA



Not sure where you got ifnull from?? did u read my post....it's nullif()
Go to Top of Page

agarwasa2008
Posting Yak Master

109 Posts

Posted - 2009-12-18 : 17:03:21
Thanks Vijayisonly!! I am a programmer by profession and so in between phone calls and myraid of other things I changed nullif to ifnull. Thanks a bunch!!

SA
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-12-18 : 17:08:25
Np. You're welcome
Go to Top of Page
   

- Advertisement -