I have the following example of table content
+ Column1 | Column2 | Column3 +
+---------|---------|---------+
+ 1 | val.txt | +
+ 2 | test.xls| +
+ 3 | abc.dwg | +
+ 4 | y.txt | +
+---------|---------|---------+
I want to update Column3 with information from Column2, which means I want to (in this case) extract the extension from Column2 and put it in Column3.
I want the result to look like
+ Column1 | Column2 | Column3 +
+---------|---------|---------+
+ 1 | val.txt | .txt +
+ 2 | test.xls| .xls +
+ 3 | abc.dwg | .dwg +
+ 4 | y.txt | .txt +
+---------|---------|---------+
How to do that with an UPDATE statement?
I know how to extract the extension:
SUBSTRING(Column2, LEN(Column2)-3, LEN(Column2)) AS Extension
How about this:
If needed, you can also include a
WHEREclause to limit the rows being updated, e.g.:or something like that.