|
Posted by othellomy on 11/03/06 10:45
select left('Hello World /Ok',charindex('/','Hello World /Ok')-1)
Hello World
That works fine.
However I got an error message:
select left('Hello World Ok',charindex('/','Hello World Ok')-1)
Instead of:
'Hello World Ok'
I get:
Server: Msg 536, Level 16, State 3, Line 1
Invalid length parameter passed to the substring function.
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."
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.
Thanks.
Navigation:
[Reply to this message]
|