SQL 自動編序號
是的,
又是這一個需求,
之前的處理方式被嫌麻煩(菜鳥工程師看不懂),
改一個簡易版實作:
1-先編流水號,並存入時的Table中
SELECT autoid,id= (SELECT COUNT(autoid) FROM SDB AS tb
WHERE tb.autoid<= TB.autoid)
INTO #tb
FROM SDB AS TB ORDER BY 1;
2-依相對key值做Update
update SDB set id=#tb.id
from #tb
自我LV~