create a sequence characters using sqlserver
STEP 1 : cliculate characters number/(countof alphabtes=26) +asci value statring from 65
declare @i int =1000
select (char(@i / 26000 % 26 + 65) +
char(@i / 1000 % 26 + 65) +
char(@i / 100 % 10 + 48) +
char(@i / 10 % 10 + 48) +
char(@i % 10 + 48))
output: AB000
declare @i int =10000
select (char(@i / 260000 % 26 + 65) +
char(@i / 10000 % 26 + 65) +
char(@i / 1000 % 26 + 48) +
char(@i / 100 % 10 + 48) +
char(@i / 10 % 10 + 48) +
char(@i % 10 + 48))
OUTPUT:AA1000
declare @i int =100
select (char(@i / 2600 % 26 + 65) +
char(@i / 100 % 10 + 48) +
char(@i / 10 % 10 + 48) +
char(@i % 10 + 48))
OUTPUT:A100
declare @i int =10
select (char(@i / 260000 % 26 + 65) +
char(@i / 10 % 10 + 48) +
char(@i % 10 + 48))
OUTPUT:A10
STEP 1 : cliculate characters number/(countof alphabtes=26) +asci value statring from 65
declare @i int =1000
select (char(@i / 26000 % 26 + 65) +
char(@i / 1000 % 26 + 65) +
char(@i / 100 % 10 + 48) +
char(@i / 10 % 10 + 48) +
char(@i % 10 + 48))
output: AB000
declare @i int =10000
select (char(@i / 260000 % 26 + 65) +
char(@i / 10000 % 26 + 65) +
char(@i / 1000 % 26 + 48) +
char(@i / 100 % 10 + 48) +
char(@i / 10 % 10 + 48) +
char(@i % 10 + 48))
OUTPUT:AA1000
declare @i int =100
select (char(@i / 2600 % 26 + 65) +
char(@i / 100 % 10 + 48) +
char(@i / 10 % 10 + 48) +
char(@i % 10 + 48))
OUTPUT:A100
declare @i int =10
select (char(@i / 260000 % 26 + 65) +
char(@i / 10 % 10 + 48) +
char(@i % 10 + 48))
OUTPUT:A10
No comments:
Post a Comment