sysobjects from another DB

  • Hi,

    Select * from sys.sysobjects where Xtype='p'-- Result is Good

    Select * from DBName.dbo.sys.sysobjects where Xtype='p'--Result is

    Msg 7202, Level 11, State 2, Line 1

    Could not find server 'DBName' in sys.servers. Verify that the correct server name was specified. If necessary, execute the stored procedure sp_addlinkedserver to add the server to sys.servers.

    Why there is a error when i run sys.Views

  • yuvipoy (1/10/2012)


    Hi,

    Select * from sys.sysobjects where Xtype='p'-- Result is Good

    Select * from DBName.dbo.sys.sysobjects where Xtype='p'--Result is

    Msg 7202, Level 11, State 2, Line 1

    Could not find server 'DBName' in sys.servers. Verify that the correct server name was specified. If necessary, execute the stored procedure sp_addlinkedserver to add the server to sys.servers.

    Why there is a error when i run sys.Views

    Assuming that you are attempting to do this from another database on the same server, this is what you need:

    Select * from DBName.sys.sysobjects where Xtype = 'p'

    Be sure to replace DBName with the actual name of the databse you want to query.

  • And actually, you probably should be using sys.objects, not sys.sysobjects as the later is for backward compatibility with SQL Server 2000 and they may be removed in a future version of SQL Server.

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

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