New training course: Customizing SQL Prompt. Watch now.
Insert statement with column list - where non-existent columns are changed to Null value on insert
Has anyone seen an easy way to do this? I want to insert values from one table to another, but the source table has 8 columns and the destination table has 30. The destination table is not permanent. The column names stay the same but it's basically a table for staging. I want to be able to quickly insert those 8 (the column names are the same) and change the non-existent column name to insert NULL or '' (either works for this purpose). I was looking for some type of scripting that finds and replaces those columns names. Like a find non-existent names of columns, replace with null kind of thing. Am I dreaming? Thanks in advance! p.s. i know I can go through and type Null on all of them, that's ok, I'll do that while waiting for the answer, but just thought I'd see if someone already knows this. I looked on Stack Overflow but it's hard to search for this without bringing up irrelevant posts. Not even sure if this could be part of SQL Prompt, grasping at straws. Thanks again!!!
0 · Share on Twitter