In SQL server 2008 I have a table, let’s say like this:
ID. | Number | details |
---|---|---|
1 | 02 | Temp |
1 | 03 | Temp/01 |
2 | 04 | Temp/04 |
How would I write an update script to use the last 2 digits of the details column to update all number columns where the ID is the same? Is this even possible?
I used:
Update Table
Set Number = RIGHT(details, 02)
Where number NOT LIKE CONCAT(‘%’, details)
But obviously that didn’t work so I added a:
AND details LIKE ‘%/%’
To sort out the details columns without a number at the end.
New contributor