Issue searching down columns

  Kiến thức lập trình

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

Paul is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT