INSERT INTO SELECT * FROM tblName IN 'Db Location'

mathematician

New Member
Joined
Aug 24, 2015
Messages
45
Hi,
I'm trying to consolidate data from multiple access databases into SQL Server. The code works fine but the only drawback is when there is a new column in a source access database table 'Db Location' it results into an error. Is there a way in SQL where I can specify to SKIP unmatched fields?
 

Some videos you may like

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

stumac

Active Member
Joined
Jul 16, 2010
Messages
471
use a copy of the database and delete the field.
 

xenou

MrExcel MVP, Moderator
Joined
Mar 2, 2007
Messages
16,673
Office Version
2013
Platform
Windows
can you give an example of what you mean by an unmatched field? Is this in your Select clause? Or your Where clause or Join clause?
 

mathematician

New Member
Joined
Aug 24, 2015
Messages
45
can you give an example of what you mean by an unmatched field? Is this in your Select clause? Or your Where clause or Join clause?
I mean some columns that are in FROM table but are not in INTO table. I want to ignore them and continue appending records. As it stands it gives an error when there is any column in the FROM table that do not exist in INTO table. My sql statement is

INSERT INTO tblINTO SELECT * FROM tblFROM IN 'tblFROM_DB_LOCATION'
 
Last edited:

xenou

MrExcel MVP, Moderator
Joined
Mar 2, 2007
Messages
16,673
Office Version
2013
Platform
Windows
There is probably no simple was to do this with plain SQL. I suppose there are tools that would allow it (such as SSIS import export mappings or who knows what else might be available these days). I could imagine ways to do this with vba but building out code like that would probably take longer than just fiddling with the tables and the SQL as you go.
 

Watch MrExcel Video

Forum statistics

Threads
1,102,481
Messages
5,487,134
Members
407,580
Latest member
nilnil1

This Week's Hot Topics

Top