create table from another table in different database in sql server code example

Example 1: migrate sql table another database

INSERT INTO dbo.YourTableNameHere
   SELECT *
   FROM [SourceServer].[SourceDatabase].dbo.YourTableNameHere

Example 2: sql select data from one database and insert into a different database

USE TargetDatabase
GO

INSERT INTO dbo.TargetTable(field1, field2, field3)
   SELECT field1, field2, field3
     FROM SourceDatabase.dbo.SourceTable
     WHERE (some condition)

Tags:

Sql Example