Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 select where first letter equals...

Author  Topic 

cDc
Starting Member

30 Posts

Posted - 2004-08-11 : 09:39:38
Hi Chaps
is there a way to perform this in one query without the if?

declare @letter char(1)
set @letter = '0'

if not isnumeric(@letter) = 1
select description from mytable where left(description,1) = @letter
else
select description from mytable where (ascii(left(description,1)) < 65 or ascii(left(description,1)) > 90)


tia!
cDc

Kristen
Test

22859 Posts

Posted - 2004-08-11 : 09:56:30
select description
from mytable
where (not isnumeric(@letter) = 1 AND left(description,1) = @letter)
OR (isnumeric(@letter) = 1 AND (ascii(left(description,1)) < 65 or ascii(left(description,1)) > 90))

Kristen
Go to Top of Page
   

- Advertisement -