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 |
ATG
Starting Member
35 Posts |
Posted - 2012-08-30 : 13:08:10
|
How do you specify a strings output length?For instance, if I have a column of names, say...BobDavidJenniferI want to make it so that the length of the output column is always 10, so if you were to run Len(Names) it would return 10 for each entry. This is probably easy but I'm having a brainfart....Thanks! |
|
Jeff Moden
Aged Yak Warrior
652 Posts |
Posted - 2012-08-30 : 13:25:05
|
Convert it to CHAR(10).--Jeff Moden |
 |
|
ATG
Starting Member
35 Posts |
Posted - 2012-08-30 : 13:33:48
|
Yeah. I tried that and it's still not working... |
 |
|
ATG
Starting Member
35 Posts |
Posted - 2012-08-30 : 13:45:03
|
LEN(CONVERT(CHAR(10),EFT.Name)) is returning different lengths. Am I doing something wrong? |
 |
|
ATG
Starting Member
35 Posts |
Posted - 2012-08-30 : 13:48:02
|
Wow. Nevermind. Len still shows the variable lengths but is outputting the desired result. Thanks! |
 |
|
Jeff Moden
Aged Yak Warrior
652 Posts |
Posted - 2012-08-31 : 13:12:28
|
Use DATALENGTH so it counts the trailing spaces.--Jeff Moden |
 |
|
|
|
|