0

I have a table A which has Id = 0 for some 6k records, another table B in which these IDs are missing. I want to insert these IDs into table B with an auto incremented ID number and update these ID numbers into table A in no particular order. just that there should be no ID = 0 in table A. I'm doing this in Python. is there a faster way of doing this rather than the regular DMLs and for loop which seems to be taking a very long time.

Thanks in advance.

olivia
  • 119
  • 1
  • 2
  • 9
  • Exactly which Sybase edition and version are you using? – Dai Nov 22 '22 at 07:25
  • @Dai - I'm using Sybase ASE 16.0 – olivia Nov 22 '22 at 07:29
  • Use Sybase's `bcp.exe` - and this: https://stackoverflow.com/questions/46443695/how-to-perform-a-bulk-insert-in-sybase-sql – Dai Nov 22 '22 at 07:30
  • what do you mean by *`these IDs are missing.`* for table B? they are `0`? they are `NULL`? the table currently has no such column? also, just to be clear ... when you say *`auto incremented ID`* ... you're referring to a column that has the `identity` attribute? – markp-fuso Nov 22 '22 at 16:04
  • 1
    is the intent: start with an empty table B, the ID column in table B has the `identity` attribute, copy rows from table A to table B so that the new rows in table B end up with system generated ID values, then move these rows back to table A ... in effect updating the ID column in table A with the newly generated `identity` values? – markp-fuso Nov 22 '22 at 16:06
  • updating 6K rows should take no more than a second (if that) so not sure how this - *`for loop which seems to be taking a very long time`* - makes sense unless there's something else going on (eg, poorly performing trigger firing on inserts, incorrect/inefficient SQL being used to modify the rows, or perhaps something else ... ?); it's going to be hard to troubleshoot the performance issue without a lot more details – markp-fuso Nov 22 '22 at 16:10

0 Answers0