Retrieving data from one database table to another database table

I imported data from MS-Access to an SQL database using the import / export wizard. I now have a database called

TestDatabase - with a table called AccessTable - it has 10 columns.

on the same SQL Server, I have another database called SampleDatabase with a table called SampleTable

I want to copy [TESTDATABASE]. [dbo]. [AccessTable] in [SampleDatabase]. [dbo]. [SampleTable]

The structure of this table is slightly different. The first two columns do not match, but all the rest are the same, and I want to copy only the mapped columns.

How to do it?

In short: I want 1000 rows from the first database insert to the second database table.

I am using SQL Server 2008 express currently.

+3
source share
1 answer

You can run this query:

INSERT INTO [SampleDatabase].[dbo].[SampleTable] (
    field1, field2, field3, field4
)
SELECT field1, field2, field3, field4
FROM [TESTDATABASE].[dbo].[AccessTable];
+5
source

All Articles