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 |
|
Stan1978
Starting Member
31 Posts |
Posted - 2011-09-22 : 08:03:49
|
| Thanks for reading.I have a 23 character length bigint and I need to select 2 characters that are 8 from the left.I have been trying - substring (Trans,8,2)What should I do as this doesn't work on bigints?? |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-09-22 : 08:17:53
|
| String Functions only work on strings, trySUBSTRING(convert(varchar(23),Trans),8,2)JimEveryday I learn something that somebody else already knew |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2011-09-22 : 08:20:00
|
| "I have a 23 character length bigint"You sure? Max BigInt is 9,223,372,036,854,775,807 which is Length=19 digitsbut this would do the conversion that you want:substring(LEFT(REPLICATE(' ', 23) + CONVERT(varchar(23), Trans),23), 8,2)you would be better off using arithmetic integer-division and modulus functions to get specific digits from a numeric value though. |
 |
|
|
Stan1978
Starting Member
31 Posts |
Posted - 2011-09-22 : 08:23:33
|
| Yes your right cant count!! But works perfectly thank you guys. |
 |
|
|
|
|
|
|
|