0

Can I Select * into a Sqlserver Table from a SqlExpress Table the way I can from a Sqlserver Table to a Sqlserver Table using

Select * into  Table2 from  Table1

If so, what is the syntax?

Lill Lansey
  • 4,775
  • 13
  • 55
  • 77

3 Answers3

3

These are distinct servers, so you would need to introduce a linked server, on the server where you intend to make a reference to the other server.

  sp_addlinkedserver @server= 'some_ip_or_URI',  @srvproduct= 'SQL Server'

Then you need to use the full name of the table/object needed in the query

  [Server Name].[Database Name].[Owner/Schema Name].[Object Name]

as in

 [test.private.mydomain.com].ClientDB.dbo.tblInvoices

Note the square brackets which are necessary of course, when the instance/server name include dots, spaces and such characters.

mjv
  • 73,152
  • 14
  • 113
  • 156
1

Most likely you will first have to link the two SQL Server instances together first. The form you'd use after that would be:

SELECT * INTO TABLE2 FROM [ServerInstanceName].[DatabaseName].[SchemaName].[TableName]
Tim Lentine
  • 7,782
  • 5
  • 35
  • 40
0

I ended up using ssms database import. Couldn't get the naming to work using select.

Lill Lansey
  • 4,775
  • 13
  • 55
  • 77