You are here: Re: Int to char conversion « MsSQL Server « IT news, forums, messages
Re: Int to char conversion

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация