Можете да генерирате списък с колони:
select name + ', '
from sys.columns
where object_id = object_id('YourTable')
and name not in ('column1', 'column2')
Възможно е да направите това в движение с динамичен SQL:
declare @columns varchar(max)
select @columns = case when @columns is null then '' else @columns + ', ' end +
quotename(name)
from sys.columns
where object_id = object_id('YourTable')
and name not in ('column1', 'column2')
declare @query varchar(max)
set @query = 'select ' + @columns + ' from YourTable'
exec (@query)