Yep... but ya gotta tell me why you want to do this, please...
... obviously, you'll need to change the constant for the table name variable and the object of the USE statement... :D
Code:
USE PUBS
GO
DECLARE @TableName VARCHAR(8000)
SET @TableName = 'dbo.Authors'
DECLARE @SQL1 VARCHAR(8000)
DECLARE @SQL2 VARCHAR(8000)
DECLARE @SQL3 VARCHAR(8000)
SELECT @SQL1 = 'SELECT '
SELECT TOP 20
@SQL2 = ISNULL(@SQL2+',','') + Name
FROM dbo.SysColumns
WHERE ID = OBJECT_ID(@TableName)
ORDER BY ColID
SELECT @SQL3 = ' FROM '+@TableName
PRINT @SQL1+@SQL2+@SQL3
EXEC (@SQL1+@SQL2+@SQL3)
--Jeff Moden