Return Table Privileges from a Linked Server in SQL Server (T-SQL Examples)

In SQL Server you can use the sp_table_privileges_ex system stored procedure to return privilege information about a specified table from a specified linked server.

You can specify an individual table, or you can specify all tables from a given database or table schema. You can also use wildcard characters to specify the table/s. However, you can also specify whether the wildcard characters should be interpreted as wildcard characters.

Continue reading

Return a List of Tables from a Linked Server in SQL Server (T-SQL Examples)

In SQL Server you can use the sp_tables_ex system stored procedure to return table information about the tables from a specified linked server.

The simplest way to execute this stored procedure is to pass the name of the linked server. Doing that will return all tables from the default database on the specified linked server, including system tables and views. This could be a big list.

You also have the option of specifying a different database and/or a specific table schema. You can also filter the results based on the table type (e.g. table, view, system table, etc).

Continue reading

Remove a Linked Server in SQL Server using T-SQL

This article provides an example of using Transact-SQL to remove a linked server in SQL Server.

To remove a linked server, use the sp_dropserver system stored procedure. This removes a server from the list of known remote and linked servers on the local instance of SQL Server. This stored procedure accepts two arguments: the server name, and an optional argument for removing any logins associated with the server.

Continue reading

2 Ways to Return a List of Linked Servers in SQL Server using T-SQL

If you find yourself needing to use Transact-SQL to get a list of all linked servers in SQL Server, below are two ways you can go about doing this.

In the first example I use the sp_linkedservers system stored procedure to return the linked servers. In the second example I use the sys.servers system catalog view.

Continue reading