gNome
asked on
SQL Server Scripting - Iterate through a number of records and then alter another table
Greetings,
I am working on an SQL Server script to automate a data cleansing routine as follows:
I need to select records in table ABC(20 rows returned)
For each record(20) that is returned I need to take a value from one of the columns in ABC(Ex: ABC.MY_COLUMN) and then use it to make an update in table XYZ (Ex: XYZ.MY_COLUMN). In other words I need to take the value from ABC.MY_COULMN and update the XYZ table with that value.
Many Thanks
I am working on an SQL Server script to automate a data cleansing routine as follows:
I need to select records in table ABC(20 rows returned)
For each record(20) that is returned I need to take a value from one of the columns in ABC(Ex: ABC.MY_COLUMN) and then use it to make an update in table XYZ (Ex: XYZ.MY_COLUMN). In other words I need to take the value from ABC.MY_COULMN and update the XYZ table with that value.
Many Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:) yep, change of thinking from loops/iterations to thinking joins seems needed.
tongue-in-cheek "translation" follows:
I am working on an SQL Server script
I am working on a query
to automate a data cleansing routine as follows:
to facilitate data cleansing
I need to select records in table ABC(20 rows returned)
I need a where clause or subquery to select from table ABC(n rows in resultset)
For each record(20) that is returned
For each match of these rows to another table; XYZ
I need to take a value from one of the columns in ABC(Ex: ABC.MY_COLUMN) and then use it to make an update in table XYZ (Ex: XYZ.MY_COLUMN).
I need to update a column of XYZ
In other words I need to take the value from ABC.MY_COLUMN and update the XYZ table with that value.
In short I need an update query
In the unlikely event: no points please
tongue-in-cheek "translation" follows:
I am working on an SQL Server script
I am working on a query
to automate a data cleansing routine as follows:
to facilitate data cleansing
I need to select records in table ABC(20 rows returned)
I need a where clause or subquery to select from table ABC(n rows in resultset)
For each record(20) that is returned
For each match of these rows to another table; XYZ
I need to take a value from one of the columns in ABC(Ex: ABC.MY_COLUMN) and then use it to make an update in table XYZ (Ex: XYZ.MY_COLUMN).
I need to update a column of XYZ
In other words I need to take the value from ABC.MY_COLUMN and update the XYZ table with that value.
In short I need an update query
In the unlikely event: no points please
Open in new window