This is an excellent question, thank you Greg. It serves as a reminder that "thou shalt not omit the size when declaring a string based variable" as it can serve as a ground of subtle bugs. For example, int and varchar are implicitly convertible and funny things can happen because of it:
create proc dbo.dump_me
(
@input varchar
)
as
begin
select @input result;
end;
go
The proc above has a nasty side effect:
exec dbo.dump_me '123';
produces
result
------
1
However, removing the single quotes:
exec dbo.dump_me 123;
produces
result
------
*
While this behaviour is by design, it might catch someone by surprise. The size is omitted, so '123' becomes 1 when cast to varchar(1), but implementation of int data type allows returning * when the number of characters in the int does not fit.
Oleg