SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Serial characters
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

samir.first
Starting Member

Egypt
34 Posts

Posted - 02/25/2014 :  03:37:20  Show Profile  Reply with Quote
I need Query
A
B
C
.
.
Z
AA
AB
.
.
AZ
AAA
AAB
. etc

nagino
Yak Posting Veteran

Japan
65 Posts

Posted - 02/25/2014 :  06:55:34  Show Profile  Reply with Quote
You select Chars
WITH BASE (letters, ascii) AS (
  SELECT CHAR(65), 65
  UNION ALL
  SELECT CHAR([ascii]+1), [ascii]+1
  FROM BASE
  WHERE [ascii] < 90
), RESULT (letters) AS (
  SELECT CONVERT(varchar(10), letters)
  FROM BASE
  UNION ALL
  SELECT CONVERT(varchar(10), RESULT.letters + BASE.letters)
  FROM RESULT
  CROSS JOIN BASE
  WHERE LEN(RESULT.letters) < 3
)
SELECT letters
FROM RESULT
ORDER BY LEN(letters), letters


-------------------------------------
From Japan
Sorry, my English ability is limited.
Go to Top of Page

samir.first
Starting Member

Egypt
34 Posts

Posted - 02/26/2014 :  09:05:57  Show Profile  Reply with Quote
Incorrect syntax near 'RESULT'.
Go to Top of Page

Lamprey
Flowing Fount of Yak Knowledge

4614 Posts

Posted - 02/26/2014 :  16:26:40  Show Profile  Reply with Quote
It looks like SQL is interpreting RESULT as a reserved word. Either make it a quoted-identifier (put square brackets) around it or rename it.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000