You are here: Re: LEFT and string function « MsSQL Server « IT news, forums, messages
Re: LEFT and string function

Posted by Hugo Kornelis on 11/03/06 22:28

On 3 Nov 2006 02:45:44 -0800, othellomy@yahoo.com wrote:

(snip)
>Microsoft Doc incorrectly says:
>"LEFT ( character_expression , integer_expression )
>integer_expression
>Is a positive whole number. If integer_expression is negative, a null
>string is returned."

Hi othellomy,

Your copy of Books Online must be outdated, then. Here's what my version
says:

"integer_expression

"Is a positive integer that specifies how many characters of the
character_expression will be returned. If integer_expression is
negative, an error is returned. integer_expression can be of
type bigint."

>Is there an easier solutoin using left or any other string function
>instead of using a case statement?
>Also, charindex('/','Hello World Ok') should return NULL instead 0 so
>that we can use isnull function.

You can use NULLIF to change the 0 to NULL yourself:

SELECT LEFT ('Hello World Ok',
NULLIF (CHARINDEX('/','Hello World Ok'), 0) - 1);

--
Hugo Kornelis, SQL Server MVP

 

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

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