November 15, 2005 at 9:35 am
Hi does anyone know the SQL for comparing the first letter of a string to a letter of your choosing????
Cheers Ehsan
November 15, 2005 at 9:41 am
IF LEFT('Letter', 1) = 'L' PRINT 'Correct' ELSE PRINT 'Wrong'
**ASCII stupid question, get a stupid ANSI !!!**
November 15, 2005 at 10:47 am
Or in a query :
where MyColum like @Letter + '%'
November 15, 2005 at 11:06 am
wow - remi and noel online at the same time - this hasn't happened for a long time..
here're some more - "just for the fun of it"..
select * from myTable where left(myCol, 1) = 'L' select * from myTable where charindex('L', myCol, 1) = 1 select * from myTable where myCol like 'L%' select * from myTable where right(reverse(myCol), 1) = 'L' select * from myTable where substring(myCol, 1, 1) = 'L'
**ASCII stupid question, get a stupid ANSI !!!**
November 15, 2005 at 11:46 am
Cool, pick out the right answer from that list now .
November 15, 2005 at 12:47 pm
He he its been a while I had to do many many things at once and the light still not at the end of the tunnel
* Noel
November 15, 2005 at 12:52 pm
It's certainly been a looooooooooong while - almost feels like another lifetime - the "good old days"...
remi - I'll let the original poster pick the "right" answer...though my preference would still be to go with "left" -
**ASCII stupid question, get a stupid ANSI !!!**
November 15, 2005 at 1:01 pm
Since when is left sargable?
November 15, 2005 at 1:19 pm
moral of the story - "search" all you want and "argue" all you want...remi's solution is ALWAYS the only right one...I only said "left" for that play on words that I can never resist...
btw - what if the column is not indexed ?!
**ASCII stupid question, get a stupid ANSI !!!**
November 15, 2005 at 1:28 pm
That's it... I'm never comming back. I'm not always right but if you guys can't live with the fact that I'm rarely wrong then Goodbye.
November 15, 2005 at 1:35 pm
oh I'm used to the fact that you're "rarely wrong"...AND since I'm not one of the "guys"..hopefully whoever you're addressing in your post will come along and respond before you "never come back"!!!!
**ASCII stupid question, get a stupid ANSI !!!**
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply