Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
j0sh1984
Starting Member
2 Posts |
Posted - 2008-11-25 : 21:46:37
|
Hi there, Is there a way to get the number with datatype varchar with specific number of digits? This is the following data7000948849470009488242700094824323232394893what i want to get is the numbers with 11 digits. I will appreciate your help. |
|
|
pbguy
Constraint Violating Yak Guru
319 Posts |
Posted - 2008-11-25 : 22:46:04
|
| select Col1from @twhere len(cast(col1 as varchar)) >= 11--------------------------------------------------S.Ahamed |
 |
|
|
j0sh1984
Starting Member
2 Posts |
Posted - 2008-11-25 : 23:03:37
|
| Thank you So much!!! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-25 : 23:11:12
|
| better to specify length while casting to varchar see thishttp://sqlblogcasts.com/blogs/madhivanan/archive/2007/12/04/column-length-and-data-length.aspx |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-11-26 : 02:01:58
|
| orselect Col1from @twhere col1+0 >= 9999999999MadhivananFailing to plan is Planning to fail |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2008-11-26 : 02:11:49
|
quote: Originally posted by madhivanan orselect Col1from @twhere col1+0 >= 9999999999MadhivananFailing to plan is Planning to fail
very lazy  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-11-26 : 02:22:26
|
What happens if some record is 11 characters but has non-numeric content?SELECT *FROM Table1WHERE Col1 LIKE REPLICATE('[0-9]', 11) E 12°55'05.63"N 56°04'39.26" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-11-26 : 02:30:13
|
quote: Originally posted by webfred
quote: Originally posted by madhivanan orselect Col1from @twhere col1+0 >= 9999999999MadhivananFailing to plan is Planning to fail
very lazy  No, you're never too old to Yak'n'Roll if you're too young to die.
MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|