Skip to content
Advertisement

Update column data using SQL query

In our SQL Server database, we are trying to update the old column data in a table. In a table there is lot of data similar to Agency Administrator. This is data is in old format where we were taking single values in a column. Now, due to an update in data structure, we are storing the data as [“Agency Administrator”]. The same change we want to do in the old data as [“Agency Administrator”]. How we can update by SQL query?

Desired result should be Agency Administrator —> [“Agency Administrator”]

Image below

Advertisement

Answer

Is this what you want?

update mytable
set adminType = '["Agency Administrator"]'
where adminType = 'Agency Administrator'

This replaces all values that are equal to 'Agency Administrator' with '["Agency Administrator"]' in column adminType.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement