0

May be this question is redundant but I am posting it as I could not get an exact solution (Please read Actual Scenario). I have the following script which returns all the tables and corresponding no. of rows.

    SELECT
        sysobjects.Name, sysindexes.Rows
    FROM
        sysobjects
        INNER JOIN sysindexes
        ON sysobjects.id = sysindexes.id
    WHERE
        type = 'U'
        AND sysindexes.IndId < 2 ORDER BY ([Rows])

Now, I want to join this result set with similar result set on a different database (with same structure). I am not able to use four partition naming with sysobjects. It gives error: The multi-part identifier "My_Database1.sysobjects.Name" could not be bound.

Actual Scenario: I have a duplicate database and want to know in which tables data has not been moved from original database.

Any alternate solution would also help.

4

3 回答 3

1

put .dbo between "My_Database1. and sysobjects.Name" as in

My_Database1.dbo.sysobjects
于 2013-07-19T10:02:06.973 回答
1

you should be ble to query sys tables on different database than the one you are connected (as long as they are on the same instance, of course). Check your sysntax, I believe you are missing the schema name sys so it would be:

SELECT * FROM My_Database1.sys.sysobjects
于 2013-07-19T10:04:57.283 回答
0

Please use sys object for system data table:

select sys_obj.* from DatabaseName.Sys.sysobjects sys_obj
于 2013-07-19T10:04:47.287 回答