Table create was skipped, but still got warning saying it was created.

  • Today I had to go back and deploy a schema change script for a legacy application still running under SQL Server 2000. There is one block of code which basically says "if the table doesn't exist, then create it." The table already exists, and the script actually didn't attempt to create it again, but I was surprised to still get a warning message about the 8060 bytes per row limitation. It's only v2000, so I don't expect anyuone to care at this point, but when the production control guy goes to execute the script, they get confused by needless warning messages. I just think it weird.

    if 0 = 1

    begin

    create table XYZ ( a varchar(8000), b varchar(8000) );

    print 'Table was created.';

    end

    else print 'Table was not created.';

    Warning: The table 'XYZ' has been created but its maximum row size (16025) exceeds the maximum number of bytes per row (8060). INSERT or UPDATE of a row in this table will fail if the resulting row length exceeds 8060 bytes.

    Table was not created.

    "Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho

  • "If" statements have to make sure every possible outcome can compile and run without errors. That's why they give errors as if an option had run that really didn't. You won't get DML errors out of them because of that, but you will get DDL errors that way.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • GSquared (10/25/2010)


    "If" statements have to make sure every possible outcome can compile and run without errors. That's why they give errors as if an option had run that really didn't. You won't get DML errors out of them because of that, but you will get DDL errors that way.

    Since SQL Server 2005/2008 we've had row overflow allocations, so that's why it's been a while that I've seen this message with a DDL script. Thanks.

    "Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho

  • Makes sense, and you're welcome.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

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

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