-- Collection of code snippets by Arne Vajhøj 
-- (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
CREATE PROCEDURE GETTABLENAMES AS

DECLARE @name  VARCHAR(32)

DECLARE c CURSOR FOR
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE'

OPEN c

FETCH NEXT FROM c INTO @name

WHILE @@FETCH_STATUS = 0
BEGIN
       PRINT @name
       FETCH NEXT FROM c INTO @name
END

CLOSE c

DEALLOCATE c

GO
