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)
 Get next letter

Author  Topic 

Sun Foster
Aged Yak Warrior

515 Posts

Posted - 2006-10-24 : 09:56:11
How to code to get next letter?
For integer, I use i = i+1, how to code in letter sequence?
If it is letter "C", I need "D", if it is "M", I need "N" and so on.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-10-24 : 10:09:37
[code]
declare @c char(1)

select @c = 'C'

select char(ascii(@c) + 1)
[/code]


KH

Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-10-24 : 10:23:01
What do you want if it's 'Z'?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-10-24 : 10:50:50
Hopefully a translation back to 'a'.
declare	@test table (ch char)

insert @test
select 'A' union all
select 'B' union all
select 'Y' union all
select 'Z'

select ch, CHAR(64 + (1 + ascii(ch) % 90) % 64)
from @test



Peter Larsson
Helsingborg, Sweden
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-10-24 : 11:02:44
quote:
Originally posted by Sun Foster

How to code to get next letter?
For integer, I use i = i+1, how to code in letter sequence?
If it is letter "C", I need "D", if it is "M", I need "N" and so on.



Why do you need this?
Can you give us more details?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -