Question: How to drop column from a table after first 5 columns in MS SQL Server.
I have a table with default 5 columns but there can be more column added dynamically. 
So I need to drop all dynamic columns without default columns. In my case first 5 columns.

Answer: 
You can use dynamic sql to do this. You need to generate the `ALTER TABLE... DROP COLUMN...` script for each column of the table. To get the columns, you need to query from `sys.columns`.

Test Data:

```
CREATE TABLE testTable(
    col1    INT IDENTITY(1,1),
    col2    INT,
    col3    INT,
    col4    INT,
    col5    INT,
    col6    INT,
    col7    INT
)

```

Dynamic SQL

```
DECLARE @sql VARCHAR(MAX) = ''

SELECT @SQL = @sql + CHAR(10) +
'ALTER TABLE testTable DROP COLUMN ' + QUOTENAME(name) + ';'
FROM sys.columns
WHERE 
    object_id = OBJECT_ID('testTable')
    AND column_id > 5

PRINT @sql
EXEC(@sql)

```

Still, what you're doing is a very bad practice.
Here is the solution which did a trick. 

```
CREATE TABLE MyTable
    (
    col1 int,
    col2 int,
    col3 int,
    col4 int,
    col5 int,
    col6 int,
    col7 int,
    col8 int,
    col9 int,
    col10 int,
    col11 int,
    )

    Select column_id 
    into #tempColID
    from sys.columns where object_id = object_id('MyTable')

    DECLARE @CurrentColumnID INT
    DECLARE @Count INT 

    SET @Count = (SELECT COUNT(*) from #tempColID)

    WHILE(@Count > 0)
    begin

    SET @CurrentColumnID = (SELECT TOP 1 * from #tempColID)

    IF(@CurrentColumnID > 5)
    BEGIN
    DECLARE @colName VARCHAR(MAX) = (Select name from sys.columns WHERE column_id = @CurrentColumnID and object_id = object_id('MyTable'))
    DECLARE @qry NVARCHAR(MAX)

    IF(@colName IS NOT NULL OR @colName <> '')
    BEGIN
    Set @qry = 'alter table MyTable
    drop column '  + @colName
    END

    EXEC sp_executesql @qry
    END

    ;WITH CTE
    AS
    (
        SELECT TOP 1 * from #tempColID
    )

    Delete from CTE
    SET @Count = (SELECT COUNT(*) from #tempColID)

    end

    drop table #tempColID

```