declare @count int = 1 declare @sqlcmd nvarchar(max) while @count < 53 begin set @sqlcmd = 'alter table postcodellsoa drop column ' + quotename(cast(@count as varchar(3))) exec (@sqlcmd) set @count = @count + 1 end
I would select just the columns you want into a new table and then drop the original table.
If you want to import from CSV sources frequently then I'd recommend using LogParser, you can then grab only the columns you want to import and avoid this extra processing. Some details in the seriesd starting here: https://www.red-gate.com/simple-talk/blogs/using-logparser-part-1/
No one has followed this question yet.