Copy table to in_memory

3705
4
Jump to solution
04-15-2016 12:57 PM
MarkVolz
Regular Contributor

I would like to copy tables to "in_memory".  Is this possible?

Background:  I noticed processing data and joins is significantly faster when I use the in_memory location.  It appears that the copy, copy rows, and feature class to feature class do not allow users to copy tables to the in memory location.

0 Kudos
1 Solution

Accepted Solutions
MarkVolz
Regular Contributor

Nevermind,   ArcGIS just needed a restart!   Using "Copy Rows" works just fine when the output table is set to "in_memory\<output table>" (without quotes).

Thanks for all of your help!

View solution in original post

0 Kudos
4 Replies
DarrenWiens2
MVP Honored Contributor

You can copy tables using Copy Rows and feature classes using Copy Features, but curiously, it seems as though Copy Rows does not respect raw path notation.

>>> arcpy.CopyRows_management("myfeatureclass",r'in_memory\table')
Runtime error  Traceback (most recent call last):  File "<string>", line 1, in <module>  File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\management.py", line 14392, in CopyRows    raise e ExecuteError: ERROR 000210: Cannot create output in_memory\table Failed to execute (CopyRows). 
>>> arcpy.CopyRows_management("myfeatureclass",r'in_memory\mytable')
<Result 'in_memory\\mytable'>

edit: on further inspection, it's not a problem reading raw notation, it is a problem creating a table named "table".

FreddieGibson
Regular Contributor II

The code most likely threw the error on your first call to Copy Rows because ​"TABLE"​ is a SQL Reserved word. You can look at the following page for more information on this topic.

Using in-memory workspace—Help | ArcGIS for Desktop

MarkVolz
Regular Contributor

Nevermind,   ArcGIS just needed a restart!   Using "Copy Rows" works just fine when the output table is set to "in_memory\<output table>" (without quotes).

Thanks for all of your help!

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

In addition to the documentation that Freddie Gibson​ references, which I strongly encourage everyone to read, I also strongly encourage people to read the Foreground and background processing documentation.  When using in_memory within ArcMap/ArcCatalog (ugh, I wish I could go back to just saying ArcGIS Desktop or Desktop), in_memory doesn't always mean in-memory when background processing is enabled.