SELECT STUFF('000000000', 9 - LEN(PTAT.PTAP_Count) + 1, LEN(PTAT.PTAP_Count), PTAT.PTAP_Count) FROM ( SELECT COUNT(1) AS PTAP_Count FROM #Detail_PTAP ) AS PTAT;
SELECT STUFF('000000000', 9 - LEN(PTAT.PTAP_Count) + 1, LEN(PTAT.PTAP_Count), PTAT.PTAP_Count) FROM ( SELECT COUNT(1) AS PTAP_Count FROM #Detail_PTAP ) AS PTAT;