I have 100 columns in a table and I want to list 99 columns except a particular one.
How to exclude that columns name?
Much faster query solution! In bold text, add your table name and column name to be remove. You can add as many fields as you want to remove.
DECLARE @query nvarchar(max)=(SELECT string_agg(COLUMN_NAME,',') FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='YOURTABLENAME'
AND COLUMN_NAME NOT IN ('REMOVEDCOLOUMN',.........))
SET @query ='select '+@query+' FROM YOURTABLENAME' EXEC sp_executesql @query;