cancel
Showing results for 
Search instead for 
Did you mean: 

Create table with datatypes from source but ONLY selected columns

chris_claydon
New Contributor

I noticed the functionality to create a second output on SELECT from database and connect that to the second input on INSERT so that the destination table can be automatically created with the correct data types.

Unfortunately I only want to select and insert a small number of columns from the original table, not all of them. Instead of creating a table with only the columns I’m selecting it is creating a table with all the same columns as the source table.

I managed to prevent this by putting in a mapper which sets the column names to null to exclude those columns, however I need to do this based on the columns which were actually selected by the SELECT rather than hard-coding it into a mapper.

What’s the best solution for this please?

Many thanks,
Chris

3 REPLIES 3

Aravind711
New Contributor II

You mean creating the table on the fly with snaplogic 2nd O/P and you want to create few columns on the table.
If my understanding is correct, may i know what database you are using, If you using select snap, instead try creating with a execute snap by placing the select query and give a try, Just a heads up!

chris_claydon
New Contributor

Hi Aravind, Yes it would be much better for me to use the Execute snap rather than the Select snap but the Execute snap does not seem to have a second output with which to pass out the table structure. I’m using JDBC snaps for the select and SQL Server snaps for the insert. The underlying database is MS SQL server on both.

Hi Chris, have you tried using the Output Fields option on the select snap? Here is the sample pipeline in the doc.

image