There is a lot in this query.
Get all column names and return all rows as a single column
DECLARE @s VARCHAR(MAX)
SELECT @S = ISNULL(@s+'+','') + ' CONVERT( VARCHAR ,' + c.name + ') + ''::'''
FROM sys.all_columns c join sys.tables t
ON c.object_id = t.object_id
WHERE t.name = '//Table Name//'
SELECT @S
EXEC( 'SELECT ' + @s + ' FROM //Table Name//' )
Get all column names and return all rows as a single column
DECLARE @s VARCHAR(MAX)
SELECT @S = ISNULL(@s+'+','') + ' CONVERT( VARCHAR ,' + c.name + ') + ''::'''
FROM sys.all_columns c join sys.tables t
ON c.object_id = t.object_id
WHERE t.name = '//Table Name//'
SELECT @S
EXEC( 'SELECT ' + @s + ' FROM //Table Name//' )
Comments
Post a Comment