|
Posted by Erland Sommarskog on 02/03/06 00:27
(jim_geissman@countrywide.com) writes:
> I have data tables that include ZIP code, as char(5). The values look
> like integers, but they are padded with leading zeroes to fill out 5
> characters, '00234'.
>
> There are SPs to look up data, with @Zip char(5) among the parameters.
> Some users call these with integer values, @Zip = 234, and SQL makes
> the conversion. Is it necesary to add the leading zeroes in the SP --
> @Zip=RIGHT('00000'+@Zip,5) -- or would SQL find this match? (234 =
> '00234'). It looks like the conversion is to '234' and the match
> fails.
Yes, you would need to pad the input parameter with leading zeroes.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
[Back to original message]
|