SELECT intRoot,  intChild2=SUBSTRING(CAST(intChild AS VARCHAR(12)), 1, LEN(CAST(intRoot AS VARCHAR(12))))
into #TMP
FROM tbMenu

SELECT * FROM #TMP WHERE intRoot <>intChild2

Advertisements