Problem with Columns added with Alter Table

Grigo, Jan-David 0 Reputation points
2023-01-16T07:02:00.2933333+00:00

Hi,

i created a table in TSQL (MSSQL) and im using a BULK-Import to add data. After that i alter the table and add new columns, because if i add the columns before the BULK-Insert, its not working. The import-file does not have the new columns included.

the problem is, that i cant work with the new columns, even if i put a go after the 'alter table'.

SSMS is underlining the new columns. In our test environment its working sometimes but not on our live-system.

Does anyone have an idea, want i can do?

thank u for your help

Janno

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,366 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Olaf Helper 43,246 Reputation points
    2023-01-16T07:44:44.54+00:00

    SSMS is underlining the new column

    SSMS is a little bit "stupid" tool and not aware of your ALTER command. Go to menue "Edit" => "IntelliSense" => "Refresh cache".

    And just because SSMS unerline the column, it doesn't mean you can not use/address the new column.

    Olaf

    0 comments No comments

  2. PercyTang-MSFT 12,426 Reputation points Microsoft Vendor
    2023-01-16T08:28:20.99+00:00

    Hi @Grigo, Jan-David

    The problem you're experiencing has little to do with using BULK-Import. After creating a new table and entering data using insert into, a new column is added, and the underline also appears when operating on the newly added column.

    For this problem, you can try the method provided by Olaf Helper.

    Best regards,

    Percy Tang


    If the answer is the right solution, please click "Accept Answer". If you have extra questions about this answer, please click "Comment".

    0 comments No comments

  3. Erland Sommarskog 107.2K Reputation points
    2023-01-16T22:45:54.4633333+00:00

    As Olaf says, SSMS is not SQL Server. If SSMS gives you read squiggles, you should still let SQL Server have the final say.

    However, a better approach is to use a format file with your BULK INSERT. In that case, you don't need do this kludge, but you can have the colunms in place from the start.

    I have an article about the bulk-load tools on my web site, which you may find helpful. It discusses format files in depth. https://www.sommarskog.se/bulkload.html


  4. Grigo, Jan-David 0 Reputation points
    2023-01-17T08:15:13.68+00:00

    Thank you very much for your help. i'll try your solutions.

    have a great day

    Janno