SELECT * FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'myTable' AND ORDINAL_POSITION = '3'
Detta påstående returnerar den tredje kolumnen i din tabell
Du skulle behöva skriva en transaktions-SQL-sats som
DECLARE @columnname nvarchar(100), @sql nvarchar(500)
SELECT @columnname = ORDINAL_POSITION FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'myTable' AND ORDINAL_POSITION = '3'
SET @sql = 'SELECT ' + @columnname + ' FROM mytable'
EXEC @sql