Friday, February 24, 2012

default value to a stored proc

I'm trying to put char(0) as the default value to a variable in a stored
procedure .But it gives me syntax error .
Is there any way to escape that. I cannot use '' or anything because we
decided to use char(0) whereever we need empty string.
Thanks
create procedure TESTING_001
@.COLUMNNAME varchar(50) = char(0)
as
print @.COLUMNNAME
GOCHAR in a valid T-SQL string function. You cannot use functions as default
values for input parameters to stored procedures/UDFs. One workaround is to
assign the parameter a constant default & change it in the first line of the
stored procedure like:
SET @.p = COALESCE(NULLIF(@.p, ''), CHAR(0)) ;
--
- Anith
( Please reply to newsgroups only )

No comments:

Post a Comment