How to avoid Error message: Column name or number of supplied values does not match table definition.

  • Is anybody know how to avoid error message to run following script without using "GO" between the "ALTER TABLE" and "INSERT INTO" which shows I comment out at below?

    CREATE TABLE #Temp

    (

    ID int,

    Names varchar(50),

    Description varchar(50)

    )

    INSERT INTO #Temp Values(1, 'Name1', 'Desc1')

    INSERT INTO #Temp Values(2, 'Name2', 'Desc2')

    ALTER TABLE #Temp Drop Column Description

    --GO

    INSERT INTO #Temp Values(1, 'Name1')

  • Why would you want to do that? Genuine question, as there may be a better way of doing what you are trying to achieve if we have more information.

  • Thanks for asking.

    Basically, what I want to do is create "a" big sql query script to cover some complex calculation. I knew that I can use some kind of break script into serveral pcs to avoid it. But just think about everything dynamic (I mean input), if you don't really know what is coming for the next run, and you want to split the incoming by using if condition or ..., then I just wonder if someone has better general solution for this.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply