Suppress SQL Error message

  • Hi,

    I have written a procedure in sql server 2000

    CREATE procedure MoveToHistory

    as

    Begin

    INSERT INTO tab_history

    SELECT * FROM tbl

    if @@ERROR <> 0

    begin

    GOTO Nextloop

    end

    Nextloop:

    PRINT 'Next Statement'

    End

    if rowsize of any tab record is more than 8060 then I get the the following error message.

    Msg 511, Level 16, State 0, Line 3

    Cannot create a row of size 8062 which is greater than the allowable maximum of 8060.

    The statement has been terminated.

    (0 row(s) affected)

    Next Statement

    In the above error message, I want to suppress the SQL Server error message and display only message ("Next Statement") given in the print statement in my stored procedure. How do I do this?

    Thanks in advance

  • SQL 2000 doesn't have a built-in way to do that.

    What you'll need to do is test for rows that are above the allowed size before you insert the data. I can't get more specific, because I don't know what your data source is, etc.

    - 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

  • Thanks GSquared..

    But we are bulk inserting rows in history table (approx 1 lakh). So if we implement this we need to check row size every time before insertion and which big is performance hit

    is there any another workaround?

  • Not in SQL 2000. At least not that I know.

    - 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