How can I import data from one table to another table in the same instance?

jfriend
Kilo Explorer

I want to import data from one table to another table in my instance. I have seen in the Import Sets and Transform Mapping sections that you don't need to identify a data source.   I have generated a table extended off of sys_import_set_row that is named after the source table with import added at the end.   I have used that table to generate a transform map with the destination table.   I mapped a couple of fields to test it, but nothing is populating in the destination table.   I was hoping to get a better step by step overview of how to build out the various components to get this working.   Any help is greatly appreciated.

4 REPLIES 4

Jacob_Andersen
ServiceNow Employee
ServiceNow Employee

Really, it comes down to correctly creating an import set row table (new table that extends sys_import_set_row) and attaching a transform map to it.   It's really that simple.



Can you look at the dictionary of your newly created table and verify that you're correctly extended sys_import_set_row?   If so, you'll see its fields in your new table.   If you add a new record to that table, check the sys_import_set_row fields to see if they're automatically populated.   If they are not, then you have not correctly attached a transform map to that table.



Hope this helps.


Thanks for the help, I will try that out. One more question if possble, I am importing all of the fields from the source to destination tables. Do I need to manually add all the fields into the import table so they can merge across to the new destination table? I did not see any easier way to add the fields from my source table.



-Jeff


Take a look at the ImportSetUtils class.   If you're consuming an XML payload and putting the result in the import set table, then the import set table will actually dynamically create fields for your.   In other words, if your source table gets a new field or two, the import set table would automatically create those for you to map to the target table.



Here's a link to that class:   ServiceNow (replace with your instance name)



Unfortunately, there is no real documentation on this class.   It is VERY useful, though.


Satyaki Bose1
ServiceNow Employee
ServiceNow Employee


Hello Jeff,



What you are asking for seems to be a bit tricky, but it's possible.


Importing data from one table to another in same SNOW instance, or in that case any instance is not possible.


Try this out.



  1. Have a scheduled import created from the source table to a temporary table.
  2. Then you will need a scheduled job that imports data from the temporary table to destination table.
  3. Step 2 would require scripting assistance and you will be doing the imports via scheduled job.


** Please note that this may have performance impact, depending on the size of the source table, fields on the source table included, and the insert function on the destination table. You can schedule this during non business hours, so that minimum no.of user are affected,