SA
The reason I want to treat empty strings as null for incoming data is that
querying data with where column contains an emty string OR is null is
slower then when you only look for nulls.
Sagheer
Jim Egan <ega...@compuserve.com> wrote in article
<01bd8321$c31785a0$a301a8c0@jegan>...
Why not create a function that will perform this for you:
CREATE FUNCTION MakeNullString(@STRING char(<max length anticipated>))
RETURNS char(<max length anticipated>)
BEGIN
declare @RETURN char(<max length anticipated>);
if @STRING is null or length(@STRING) = 0 then
SET @RETURN = null
else
set @RETURN = @STRING
end if;
return(@RETURN);
END
and perform:
UPDATE TABLE SET COL1 = MakeNullString( '' ); -- Set COL = NULL
UPDATE TABLE SET COL1 = MakeNullString( null ); -- Set COL = NULL
UPDATE TABLE SET COL1 = MakeNullString( 'test' ); -- Set COL = 'test'
The above is from memory (i.e. syntax errors may exist). Hope this helps.
Jason Hinsperger
Product Quality Engineering
Sybase SQL Anywhere
I'll change my argument somewhat. It takes more to query against a column
that allows NULL (since you have to check for the absence of a value or if
it is NULL -> col1 <> '1' or col1 IS NULL) than one that doesn't allow
Darrell Guard wrote in message <3561C0...@netcom.ca>...