Monday, December 7, 2009

Using sp_msforeachtable on remote databases

Yes you can! The only proviso is that your linked server must have RPC and RPC Out enabled.
  1. Right-click the Linked Server and select properties
  2. Select Server Options
  3. Click RPC & RPC Out and OK
Then you can do wild stuff like

exec [remoteserver].[remotedb].[dbo].sp_MSforeachtable "ALTER TABLE ? DISABLE TRIGGER ALL"

No comments: