0

I need to copy several tables and views from one server to another. When I have to do this between databases I use the "USE databasename" at the beginning, with the script I generate using the sql server wizard. I have both servers connected to management, but it would be faster if I didn't have to switch between them. I tried with "USE ipserver" and "USE nameofserver" but it didn't work

  • `USE` switches the context of the database you are connected to on the instance, *not* the instance you are connected to. You could, however, use SQLCMD mode in SSMS (or a different application that supports it) to switch the connection context to a different instance. See this question, which explains how to turn on SQLCMD mode, and switch the connection: [What is the T-SQL syntax to connect to another SQL Server?](https://stackoverflow.com/questions/125457/what-is-the-t-sql-syntax-to-connect-to-another-sql-server) (Note that despite the title, this is *not* T-SQL syntax.) – Larnu Apr 07 '22 at 15:41

0 Answers0