-- Collection of code snippets by Arne Vajhøj 
-- posted to eksperten.dk, usenet and other places (2002-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
