1

I have emergency contact information attached to contact records that I am making into their own contact records.

I need to assign a temporary id to the new contact records for migration purposes.

I was hoping to do this within my SQL query that retrieves the data for creating the new records.

I found references to updating the SQL table to add a new column, but that's not what I want. I can do it after in Excel, but would prefer a one step process. Is there a way to do this?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

2

If this is a one time thing you can use row_number()

SELECT 
  *,
  ROW_NUMBER() OVER (ORDER BY SomeColumn) as TempID
FROM YourTable
WHERE...
SQLChao
  • 7,709
  • 1
  • 17
  • 32