Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2009
    Posts
    4

    Unanswered: Multiple Rows in SQL Server 2008

    We are converting from Db2 to SQL Server 2008. In Db2, my program returns -811 as SQL code if my Select query returns multiple rows. How do I get the same or similar return code in SQL Server 2008. Currently as I found, SQL server returns 0 and fetches first record if there are multiple rows. There is no inforamtion or hint that would say there are multiple rows. My program has special logic if there are multiple rows and now that logic doestn work because SQL server 2008 doesnt tell the error.

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    [dull explosion]
    You can hear the heads of the SQL Community
    [/dull explosion]


    -811

    Yeah, ALL SQL Conds should be checked....SQL server is a little more "relaxed"

    Not sure about 2k8

    Buy

    Even their BEGIN/TRY CATCH doesn't do it...because the front end apps don't care


    AHHH...but there are a few of us that still like to give them pain...by telling them, they have problems they didn't think about


    anyway

    DECLARE @error int, @rowcount int
    SELECT ....FROM...

    SELECT @error = @@ERROR, @rowcount = @@ROWCOUNT

    IF @@ERROR <> 0 -- System error
    BEGIN
    handle error
    GOTO...
    END

    IF @@ROWCOUNT > 1 -- -811
    BEGIN
    handle error
    GOTO...
    END

    IF @@ROWCOUNT = 0 -- -100
    BEGIN
    handle error
    GOTO...
    END


    ect
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Dec 2009
    Posts
    4

    Thumbs up Multiple Rows

    Thanks for the suggestin. it worked great.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •