469,273 Members | 1,878 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,273 developers. It's quick & easy.

I need help in SQL table

2
i have a table named tblPerson. There is a field in it named PersonID. the data type of the PersonID is nvarchar(5).
there were 9999 rows in the table when i added the series of 10000-10010 it is not sorting the data as it should it. it is showing 10001 - 10010 after the rows of 1000 which is wrong why is it what should i do?

currently
1000
10001
10002
10003
1001

required
1000
1001
10001
10002
10003
Jul 11 '07 #1
6 954
hariharanmca
1,977 1GB
i have a table named tblPerson. There is a field in it named PersonID. the data type of the PersonID is nvarchar(5).
there were 9999 rows in the table when i added the series of 10000-10010 it is not sorting the data as it should it. it is showing 10001 - 10010 after the rows of 1000 which is wrong why is it what should i do?

currently
1000
10001
10002
10003
1001

required
1000
1001
10001
10002
10003
if u sort the character it just by number of charecter serial

Expand|Select|Wrap|Line Numbers
  1. ex :
  2.  for 4 dig
  3. 1000
  4. 1000
  5. 1000
  6. 1000
  7. 1001
  8.  
  9.  
  10.  for 5th dig
  11. 1000
  12. 10001
  13. 10002
  14. 10003
  15. 1001

got the concept?
Jul 11 '07 #2
Kashan
2
if u sort the character it just by number of charecter serial

Expand|Select|Wrap|Line Numbers
  1. ex :
  2.  for 4 dig
  3. 1000
  4. 1000
  5. 1000
  6. 1000
  7. 1001
  8.  
  9.  
  10.  for 5th dig
  11. 1000
  12. 10001
  13. 10002
  14. 10003
  15. 1001

got the concept?
hi,
i did not understand what u wanted to say.
kindly clear by clearified example .
Thanks
Jul 11 '07 #3
hariharanmca
1,977 1GB
hi,
i did not understand what u wanted to say.
kindly clear by clearified example .
Thanks
1. You told the data type is varchar.
2. So, it will not sort the numbers lesser to greater
3. it will look for the order 0 – 9 like

Ex :

For 1 digit it’ll be correct
0
1
2
3
4
5
6
7
8
9

For 2 digit it’ll change like
0
1
10
11
12
13
14
15
16
17
18
19
2
20
21
.
.
.
Etc…,
Jul 11 '07 #4
hariharanmca
1,977 1GB
hi,
i did not understand what u wanted to say.
kindly clear by clearified example .
Thanks
did you got the concept
Jul 11 '07 #5
Vidhura
99
i have a table named tblPerson. There is a field in it named PersonID. the data type of the PersonID is nvarchar(5).
there were 9999 rows in the table when i added the series of 10000-10010 it is not sorting the data as it should it. it is showing 10001 - 10010 after the rows of 1000 which is wrong why is it what should i do?

currently
1000
10001
10002
10003
1001

required
1000
1001
10001
10002
10003
Change the PersonID to int type
Jul 11 '07 #6
hariharanmca
1,977 1GB
Change the PersonID to int type


Absolutely. You've to cahnge.........
Jul 11 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

21 posts views Thread by Johan Tibell | last post: by
25 posts views Thread by Jon Slaughter | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.