Read from one table, do Calculations based on the read columns and insert the calculated columns in another table

Raul, Sushil 0 Reputation points
2023-07-07T10:33:51.2266667+00:00

We are using Azure SQL Database, recently we have added a new table (B) to our database. The requirement here is:

a. Read the values from table A, read row by row with individual row at a time.

b. Do calculations based on the record read from table A, form an insert statement with the calculated values and insert these calculated value as a single row in table B.

Both table A and table B have 8 millions records individually.

Can anyone suggest the best way of doing this in Azure without impacting the db performance or anything else?

Azure SQL Database
{count} votes

2 answers

Sort by: Most helpful
  1. ShaktiSingh-MSFT 16,171 Reputation points
    2023-07-10T05:38:07.32+00:00

    Hi
    Raul, Sushil
    •,

    Welcome to Microsoft Q&A forum and thanks for using Azure Services.

    As I understand, you have scenario to Read from one table, do Calculations based on the read columns and insert the calculated columns in another table.

    For this usecase, please share more information about the data in the form of sample input and expected output data, the type of calculation needed to be performed etc so that we can better assist you.

    As per the existing understanding, we can suggest you to create Stored Procedure and perform the calculations.

    Alternatively, you can use Azure Data Factory/Azure Synapse Analytics pipelines to achieve this scenario.

    Thank you.

    0 comments No comments

  2. Olaf Helper 45,616 Reputation points
    2023-07-13T06:13:43.8666667+00:00

    read row by row with individual row at a time.

    Normally one creates set-based solutions and do not loop through records.

    Please post table design as DDL, some sample data as DML statement and the expected result.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.