La stored procedure sp_tables_ex restituisce metadati di tabelle e viste da un server collegato. Puoi elencare tutti gli oggetti, limitare il risultato a un database o schema specifico oppure filtrare per tipo di oggetto.
Sintassi
sp_tables_ex
[ @table_server = ] 'linked_server_name',
[ , [ @table_name = ] 'table_name' ]
[ , [ @table_schema = ] 'table_schema' ]
[ , [ @table_catalog = ] 'table_catalog' ]
[ , [ @table_type = ] 'table_type' ]
[ , [ @fUsePattern = ] 'fUsePattern' ]Tabella specifica
EXEC sp_tables_ex
@table_server = 'Homer',
@table_catalog = 'Music',
@table_name = 'Artists';Solo viste
EXEC sp_tables_ex
@table_server = 'Homer',
@table_catalog = 'Music',
@table_type = 'VIEW';I tipi validi includono TABLE, VIEW, SYSTEM TABLE, SYSTEM VIEW, SYNONYM e tipi di tabella temporanea.
Wildcard
EXEC sp_tables_ex
@table_server = 'Homer',
@table_catalog = 'WideWorldImportersDW',
@table_name = 'C%',
@table_type = 'TABLE',
@fUsePattern = 1;Imposta @fUsePattern a 0 se i caratteri jolly devono essere trattati letteralmente.