473,387 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to add characters exactly 25

ddtpmyra
333 100+
Here's my case...
I need to allocate exact 25 characters on a field. For instance the name is Lucy this means I have to add 21 extra spaces at the end.

How can I do that on my select statement?

Expand|Select|Wrap|Line Numbers
  1.  select name,25-LEN(name) as difference,
  2.  case when 
  3.  25-LEN(name)<25 
  4.  then 
  5.  ??????????
  6.  else 
  7.  ???????? end len
  8.  from person
Nov 1 '12 #1

✓ answered by ddtpmyra

OR....

Expand|Select|Wrap|Line Numbers
  1. Select UPPER(LEFT(name+space(25),25))

4 2387
ddtpmyra
333 100+
I thought of this…

Adding 25 blank space at the end of the last_name and only select the 25 char from the left.

Expand|Select|Wrap|Line Numbers
  1. Select UPPER(LEFT(name+'                         ',25))
  2.  
Nov 1 '12 #2
ddtpmyra
333 100+
OR....

Expand|Select|Wrap|Line Numbers
  1. Select UPPER(LEFT(name+space(25),25))
Nov 2 '12 #3
Rabbit
12,516 Expert Mod 8TB
Or
Expand|Select|Wrap|Line Numbers
  1. [name] + SPACE(25-LEN([name]))
Nov 2 '12 #4
ck9663
2,878 Expert 2GB
If the field "name" is a character and not a varchar, you might want to trim it first before adding any space.

Happy Coding!!!


~~ CK
Nov 2 '12 #5

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

Similar topics

43
by: Vladimir | last post by:
Method UnicodeEncoding.GetMaxByteCount(charCount) returns charCount * 2. Method UTF8Encoding.GetMaxByteCount(charCount) returns charCount * 4. But why that? Look: /* Each Unicode character...
2
by: Riku Kangas | last post by:
Hi, I have a web service with a javascript line like this to send user input to another frame: <code> parent.isk_artlist_top.location.href='artlist_top.asp?ss='+escape(document.h...
7
by: Matt L. | last post by:
In summary, I don't know how/why the following code works and would like to know. I'm trying to match the first 3 characters of a variable (filename). The code below crudely works, but only if I...
35
by: David Mathog | last post by:
Every so often one of my fgets() based programs encounters an input file containing embedded nulls. fgets is happy to read these but the embedded nulls subsequently cause problems elsewhere in...
16
by: thenightfly | last post by:
Ok, I know all about how binary numbers translate into text characters. My question is what exactly IS a text character? Is it a bitmap?
8
by: csanjith | last post by:
Hi, i have a situaion where i need to convert the characters entered in an text field to upper case using C. The configuration id utf8 environment in which user can enter any character (single ,...
5
by: Timothy Madden | last post by:
Hello Is there a function that will allow me to output text written in utf-8 (from db for example) if my document has Content-Type: text/html; charset=ISO-8859-1 I mean htmlspecialchars()...
6
by: Phil Barber | last post by:
I am using Regex to validate a file name. I have everything I need except I would like the dot(.) in the filename only to appear once. My question is it possible to allow one instance of character...
7
by: blaine | last post by:
Hey everyone, For the regular expression gurus... I'm trying to write a string matching algorithm for genomic sequences. I'm pulling out Genes from a large genomic pattern, with certain start...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.