How do I code this in Access SQL?

  • Thread starter Thread starter Duane Hookom
  • Start date Start date
D

Duane Hookom

This should do it:
SELECT TOP 26 Chr((SELECT COUNT(*)+65 FROM msysobjects m where m.ID
<msysobjects.id)) AS Letter
FROM MSysObjects
ORDER BY MSysObjects.Id;
 
I want to return all the letters in the alphabet in sequence.

In T-SQL I can do this easily as:

DECLARE @i int
SET @i=97
WHILE @i <=122
BEGIN
PRINT CHAR(@i)
SET @i=@i+1
END


But how do I do it in Access SQL?

I figure I need to do the loop in VBA but how do I geneate the letters? I
get a "function undefined" error when I try to execute:

SELECT CHAR(97)


Is there anything comparable in Access?

Also, how would I write this in Access SQL:.

IF EXISTS (SELECT * from authors WHERE au_lname like 'w%')
Print 'x'

Thanks
Dave
 
Back
Top