daidaluus
Yak Posting Veteran
73 Posts |
Posted - 2009-03-08 : 06:38:12
|
Sometimes I have to import data into a sql table from an excel sheet. that table has an id and a seq field.CREATE TABLE tbl (id int primary key, seq int)Smaller ids should have smaller seq values. and sometimes this rule is violated. for the following sample data:INSERT INTO tblSELECT 1, 870114 UNION ALLSELECT 26, 870129 UNION ALLSELECT 27, 871108 UNION ALLSELECT 28, 870129 UNION ALLSELECT 80, 870304 UNION ALLSELECT 81, 871215 UNION ALLSELECT 86, 870508 UNION ALLSELECT 94, 870312 UNION ALLSELECT 108, 870328 UNION ALLSELECT 111, 870329 UNION ALLSELECT 112, 870508 UNION ALLSELECT 116, 870401 UNION ALLSELECT 143, 870421 UNION ALLSELECT 144, 870328 UNION ALLSELECT 154, 870501 UNION ALLSELECT 160, 870328 UNION ALLSELECT 162, 870503 UNION ALLSELECT 189, 870517 UNION ALLSELECT 190, 870328 UNION ALLSELECT 194, 870519 UNION ALLSELECT 205, 870528 UNION ALLSELECT 206, 870328 UNION ALLSELECT 208, 870531 UNION ALLSELECT 226, 870614 UNION ALLSELECT 227, 870328 UNION ALLSELECT 228, 870614 UNION ALLSELECT 263, 870727 UNION ALLSELECT 264, 871108 UNION ALLSELECT 271, 870728 UNION ALLSELECT 323, 870924 UNION ALLSELECT 324, 871120 UNION ALLSELECT 327, 871003 UNION ALLSELECT 354, 871108 UNION ALLSELECT 356, 871120 UNION ALLSELECT 358, 871110 UNION ALLSELECT 361, 871114 UNION ALLSELECT 364, 871120ids 27, 81, 86, 112, 144, 160, 190, 206, 227, 264, 324, 356, 358 are out of sequence.and i want to find these id with their seq values. How can i get this result? |
|