use pubs
go
create function test ( @ci char( 1 ) )
returns bit
as
begin
return( CASE WHEN NULLIF( @ci , space( 1) ) is not null then 0 else 1 end )
end
go
declare @ci char( 1 ) , @y bit
set @ci =' '
-- Call using EXECUTE
exec @y = test @ci
select @y as IsBlank
/*
IsBlank
-------
1
*/
set @ci ='A'
-- Call as a function using SET
set @y = dbo.test( @ci )
select @y as IsBlank
/*
IsBlank
-------
0
*/
set @ci ='b'
-- Call as a function using SELECT
select @y = dbo.test( @ci )
select @y as IsBlank
/*
IsBlank
-------
0
*/
set @ci ='V'
-- Call a similar system function
set @y = fn_chariswhitespace( @ci )
select @y as IsBlank
/*
IsBlank
-------
0
*/
This page was last updated on May 01, 2006 04:28 PM.