Paste this into a new question or an answer at dba.stackexchange.com:
<!-- --> > CREATE TABLE TPAPQB01([GsmpPtIndex] varchar(40));INSERT INTO TPAPQB01([GsmpPtIndex])VALUES(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL); > GO > > <pre> 482 rows affected > </pre> <!-- --> > --Update Logic Script > with cte as ( > select GsmpPtIndex, > 'PAP_' > + right('0000'+convert(varchar(20), > ROW_NUMBER() over (order by GsmpPtIndex) > ),4) as NewGsmpPtIndex > from [TPAPQB01] > ) > update cte set GsmpPtIndex = NewGsmpPtIndex; > > --Check > select * from [TPAPQB01] > GO > > <pre> > | GsmpPtIndex | > | :---------- | > | PAP_0001 | > | PAP_0002 | > | PAP_0003 | > | PAP_0004 | > | PAP_0005 | > | PAP_0006 | > | PAP_0007 | > | PAP_0008 | > | PAP_0009 | > | PAP_0010 | > | PAP_0011 | > | PAP_0012 | > | PAP_0013 | > | PAP_0014 | > | PAP_0015 | > | PAP_0016 | > | PAP_0017 | > | PAP_0018 | > | PAP_0019 | > | PAP_0020 | > | PAP_0021 | > | PAP_0022 | > | PAP_0023 | > | PAP_0024 | > | PAP_0025 | > | PAP_0026 | > | PAP_0027 | > | PAP_0028 | > | PAP_0029 | > | PAP_0030 | > | PAP_0031 | > | PAP_0032 | > | PAP_0033 | > | PAP_0034 | > | PAP_0035 | > | PAP_0036 | > | PAP_0037 | > | PAP_0038 | > | PAP_0039 | > | PAP_0040 | > | PAP_0041 | > | PAP_0042 | > | PAP_0043 | > | PAP_0044 | > | PAP_0045 | > | PAP_0046 | > | PAP_0047 | > | PAP_0048 | > | PAP_0049 | > | PAP_0050 | > | PAP_0051 | > | PAP_0052 | > | PAP_0053 | > | PAP_0054 | > | PAP_0055 | > | PAP_0056 | > | PAP_0057 | > | PAP_0058 | > | PAP_0059 | > | PAP_0060 | > | PAP_0061 | > | PAP_0062 | > | PAP_0063 | > | PAP_0064 | > | PAP_0065 | > | PAP_0066 | > | PAP_0067 | > | PAP_0068 | > | PAP_0069 | > | PAP_0070 | > | PAP_0071 | > | PAP_0072 | > | PAP_0073 | > | PAP_0074 | > | PAP_0075 | > | PAP_0076 | > | PAP_0077 | > | PAP_0078 | > | PAP_0079 | > | PAP_0080 | > | PAP_0081 | > | PAP_0082 | > | PAP_0083 | > | PAP_0084 | > | PAP_0085 | > | PAP_0086 | > | PAP_0087 | > | PAP_0088 | > | PAP_0089 | > | PAP_0090 | > | PAP_0091 | > | PAP_0092 | > | PAP_0093 | > | PAP_0094 | > | PAP_0095 | > | PAP_0096 | > | PAP_0097 | > | PAP_0098 | > | PAP_0099 | > | PAP_0100 | > | PAP_0101 | > | PAP_0102 | > | PAP_0103 | > | PAP_0104 | > | PAP_0105 | > | PAP_0106 | > | PAP_0107 | > | PAP_0108 | > | PAP_0109 | > | PAP_0110 | > | PAP_0111 | > | PAP_0112 | > | PAP_0113 | > | PAP_0114 | > | PAP_0115 | > | PAP_0116 | > | PAP_0117 | > | PAP_0118 | > | PAP_0119 | > | PAP_0120 | > | PAP_0121 | > | PAP_0122 | > | PAP_0123 | > | PAP_0124 | > | PAP_0125 | > | PAP_0126 | > | PAP_0127 | > | PAP_0128 | > | PAP_0129 | > | PAP_0130 | > | PAP_0131 | > | PAP_0132 | > | PAP_0133 | > | PAP_0134 | > | PAP_0135 | > | PAP_0136 | > | PAP_0137 | > | PAP_0138 | > | PAP_0139 | > | PAP_0140 | > | PAP_0141 | > | PAP_0142 | > | PAP_0143 | > | PAP_0144 | > | PAP_0145 | > | PAP_0146 | > | PAP_0147 | > | PAP_0148 | > | PAP_0149 | > | PAP_0150 | > | PAP_0151 | > | PAP_0152 | > | PAP_0153 | > | PAP_0154 | > | PAP_0155 | > | PAP_0156 | > | PAP_0157 | > | PAP_0158 | > | PAP_0159 | > | PAP_0160 | > | PAP_0161 | > | PAP_0162 | > | PAP_0163 | > | PAP_0164 | > | PAP_0165 | > | PAP_0166 | > | PAP_0167 | > | PAP_0168 | > | PAP_0169 | > | PAP_0170 | > | PAP_0171 | > | PAP_0172 | > | PAP_0173 | > | PAP_0174 | > | PAP_0175 | > | PAP_0176 | > | PAP_0177 | > | PAP_0178 | > | PAP_0179 | > | PAP_0180 | > | PAP_0181 | > | PAP_0182 | > | PAP_0183 | > | PAP_0184 | > | PAP_0185 | > | PAP_0186 | > | PAP_0187 | > | PAP_0188 | > | PAP_0189 | > | PAP_0190 | > | PAP_0191 | > | PAP_0192 | > | PAP_0193 | > | PAP_0194 | > | PAP_0195 | > | PAP_0196 | > | PAP_0197 | > | PAP_0198 | > | PAP_0199 | > | PAP_0200 | > | PAP_0201 | > | PAP_0202 | > | PAP_0203 | > | PAP_0204 | > | PAP_0205 | > | PAP_0206 | > | PAP_0207 | > | PAP_0208 | > | PAP_0209 | > | PAP_0210 | > | PAP_0211 | > | PAP_0212 | > | PAP_0213 | > | PAP_0214 | > | PAP_0215 | > | PAP_0216 | > | PAP_0217 | > | PAP_0218 | > | PAP_0219 | > | PAP_0220 | > | PAP_0221 | > | PAP_0222 | > | PAP_0223 | > | PAP_0224 | > | PAP_0225 | > | PAP_0226 | > | PAP_0227 | > | PAP_0228 | > | PAP_0229 | > | PAP_0230 | > | PAP_0231 | > | PAP_0232 | > | PAP_0233 | > | PAP_0234 | > | PAP_0235 | > | PAP_0236 | > | PAP_0237 | > | PAP_0238 | > | PAP_0239 | > | PAP_0240 | > | PAP_0241 | > | PAP_0242 | > | PAP_0243 | > | PAP_0244 | > | PAP_0245 | > | PAP_0246 | > | PAP_0247 | > | PAP_0248 | > | PAP_0249 | > | PAP_0250 | > | PAP_0251 | > | PAP_0252 | > | PAP_0253 | > | PAP_0254 | > | PAP_0255 | > | PAP_0256 | > | PAP_0257 | > | PAP_0258 | > | PAP_0259 | > | PAP_0260 | > | PAP_0261 | > | PAP_0262 | > | PAP_0263 | > | PAP_0264 | > | PAP_0265 | > | PAP_0266 | > | PAP_0267 | > | PAP_0268 | > | PAP_0269 | > | PAP_0270 | > | PAP_0271 | > | PAP_0272 | > | PAP_0273 | > | PAP_0274 | > | PAP_0275 | > | PAP_0276 | > | PAP_0277 | > | PAP_0278 | > | PAP_0279 | > | PAP_0280 | > | PAP_0281 | > | PAP_0282 | > | PAP_0283 | > | PAP_0284 | > | PAP_0285 | > | PAP_0286 | > | PAP_0287 | > | PAP_0288 | > | PAP_0289 | > | PAP_0290 | > | PAP_0291 | > | PAP_0292 | > | PAP_0293 | > | PAP_0294 | > | PAP_0295 | > | PAP_0296 | > | PAP_0297 | > | PAP_0298 | > | PAP_0299 | > | PAP_0300 | > | PAP_0301 | > | PAP_0302 | > | PAP_0303 | > | PAP_0304 | > | PAP_0305 | > | PAP_0306 | > | PAP_0307 | > | PAP_0308 | > | PAP_0309 | > | PAP_0310 | > | PAP_0311 | > | PAP_0312 | > | PAP_0313 | > | PAP_0314 | > | PAP_0315 | > | PAP_0316 | > | PAP_0317 | > | PAP_0318 | > | PAP_0319 | > | PAP_0320 | > | PAP_0321 | > | PAP_0322 | > | PAP_0323 | > | PAP_0324 | > | PAP_0325 | > | PAP_0326 | > | PAP_0327 | > | PAP_0328 | > | PAP_0329 | > | PAP_0330 | > | PAP_0331 | > | PAP_0332 | > | PAP_0333 | > | PAP_0334 | > | PAP_0335 | > | PAP_0336 | > | PAP_0337 | > | PAP_0338 | > | PAP_0339 | > | PAP_0340 | > | PAP_0341 | > | PAP_0342 | > | PAP_0343 | > | PAP_0344 | > | PAP_0345 | > | PAP_0346 | > | PAP_0347 | > | PAP_0348 | > | PAP_0349 | > | PAP_0350 | > | PAP_0351 | > | PAP_0352 | > | PAP_0353 | > | PAP_0354 | > | PAP_0355 | > | PAP_0356 | > | PAP_0357 | > | PAP_0358 | > | PAP_0359 | > | PAP_0360 | > | PAP_0361 | > | PAP_0362 | > | PAP_0363 | > | PAP_0364 | > | PAP_0365 | > | PAP_0366 | > | PAP_0367 | > | PAP_0368 | > | PAP_0369 | > | PAP_0370 | > | PAP_0371 | > | PAP_0372 | > | PAP_0373 | > | PAP_0374 | > | PAP_0375 | > | PAP_0376 | > | PAP_0377 | > | PAP_0378 | > | PAP_0379 | > | PAP_0380 | > | PAP_0381 | > | PAP_0382 | > | PAP_0383 | > | PAP_0384 | > | PAP_0385 | > | PAP_0386 | > | PAP_0387 | > | PAP_0388 | > | PAP_0389 | > | PAP_0390 | > | PAP_0391 | > | PAP_0392 | > | PAP_0393 | > | PAP_0394 | > | PAP_0395 | > | PAP_0396 | > | PAP_0397 | > | PAP_0398 | > | PAP_0399 | > | PAP_0400 | > | PAP_0401 | > | PAP_0402 | > | PAP_0403 | > | PAP_0404 | > | PAP_0405 | > | PAP_0406 | > | PAP_0407 | > | PAP_0408 | > | PAP_0409 | > | PAP_0410 | > | PAP_0411 | > | PAP_0412 | > | PAP_0413 | > | PAP_0414 | > | PAP_0415 | > | PAP_0416 | > | PAP_0417 | > | PAP_0418 | > | PAP_0419 | > | PAP_0420 | > | PAP_0421 | > | PAP_0422 | > | PAP_0423 | > | PAP_0424 | > | PAP_0425 | > | PAP_0426 | > | PAP_0427 | > | PAP_0428 | > | PAP_0429 | > | PAP_0430 | > | PAP_0431 | > | PAP_0432 | > | PAP_0433 | > | PAP_0434 | > | PAP_0435 | > | PAP_0436 | > | PAP_0437 | > | PAP_0438 | > | PAP_0439 | > | PAP_0440 | > | PAP_0441 | > | PAP_0442 | > | PAP_0443 | > | PAP_0444 | > | PAP_0445 | > | PAP_0446 | > | PAP_0447 | > | PAP_0448 | > | PAP_0449 | > | PAP_0450 | > | PAP_0451 | > | PAP_0452 | > | PAP_0453 | > | PAP_0454 | > | PAP_0455 | > | PAP_0456 | > | PAP_0457 | > | PAP_0458 | > | PAP_0459 | > | PAP_0460 | > | PAP_0461 | > | PAP_0462 | > | PAP_0463 | > | PAP_0464 | > | PAP_0465 | > | PAP_0466 | > | PAP_0467 | > | PAP_0468 | > | PAP_0469 | > | PAP_0470 | > | PAP_0471 | > | PAP_0472 | > | PAP_0473 | > | PAP_0474 | > | PAP_0475 | > | PAP_0476 | > | PAP_0477 | > | PAP_0478 | > | PAP_0479 | > | PAP_0480 | > | PAP_0481 | > | PAP_0482 | > </pre> *db<>fiddle [here](https://dbfiddle.uk/?rdbms=sqlserver_2012&fiddle=f7076c525e21f2b1cd18482d96bf3532)*
back to fiddle