SELECT returns different results due to login

  • Hi All,

    I have a weird situation here. Basically when i connect thru SQL Query Analyzer to a db and use 'sa' account and do 'SELECT * from tableA' - it returns all expected rows.

    However, when i login using accountB, which has no roles specified and is only granted public, dbo, datawriter, datareader to the specific db - i run the same SELECT statement but it only returns one row?! Ive tried this on a couple machines and its the same result.

    I thought that maybe SET ROWCOUNT was set for the particular session but it wasn't.

    The row that is returned is the same row i get when doing SELECT top 1* from tableA (when using sa acct) - is that a clue to something?

    Can anybody explain why one acct would return the complete resultset but the other account returns only one row?

    Thanks in advance!

  • quote:


    Can anybody explain why one acct would return the complete resultset but the other account returns only one row?


    Maybe someone has been naughty with you and CREATEd a VIEW (Called tableA) OWNED by accountB that just is doing a 'SELECT TOP 1 * FROM [dbo].[tableA]'? Observe the reference to the Owner (in this case the DBO and not accountB)

    Regards, Hans!

  • I agree, open EM and look at the objects and see if any have the same name but different owners. It is a best practice to make sure all objects are owned by dbo so you don't run into these issues.

  • you guys/gals (sorry cant tell =) are completely right! i went under EM, looked under objects and there it was..two objects with 2 different owners! good catch ppl, now i have to try and figure out how/why this was done..thx again!

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

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