Skip to Content
0
Former Member
Aug 18, 2016 at 03:12 PM

Strange result with ROW_count and systabstats

54 Views

use master ---> DB name is different than from clause .

go

select Table_Name=convert(char(30),name),ROW=row_count(db_id(),id)

from ops..sysobjects where type='U' and name='XXXX'

go

>>>>> NO RESULT

use ops

go

select Table_Name=convert(char(30),name),ROW=row_count(db_id(),id)

from ops..sysobjects where type='U' and name='XXXX'

go

>>>>> Got result

Note : Same issue with systabstats (Now result if use <DB> and <>.systabstats -- referring different database .

is this feature or bug ?

use master

go

select rowcnt,* from pos..systabstats where object_name(id)='P_PosBatchRpt'

go

>>>>>>>>>>> NO result

use pos

go

select rowcnt,* from pos..systabstats where object_name(id)='P_PosBatchRpt'

go

>>>>>>>>>>>> Got result .