Solved

Add trailing spaces to a field

Posted on 2008-06-12
6
717 Views
Last Modified: 2010-04-21
How to I add trailing sapces to a field that will be exported to a .csv file
0
Comment
Question by:morang
  • 3
  • 2
6 Comments
 
LVL 44

Expert Comment

by:GRayL
ID: 21772583
You can only add trailing spaces using a query:

Update myTable set myFld = myFld & "   ";

three spaces for example
0
 

Author Comment

by:morang
ID: 21772600
will that work if the number of spaces is not the same for every record?
0
 
LVL 44

Accepted Solution

by:
GRayL earned 500 total points
ID: 21772648
If you have a length you want to create then

UPDATE myTable SET myFld = Trim(myFld) & Space(30 - Len(Trim(myFld)));
-----------------------------------------------------------------^-- length of field with trailing spaces

In no case can the actual trimmed field length exceed the length you set.
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Closing Comment

by:morang
ID: 31466685
Thank you for your help
0
 

Expert Comment

by:bmoabc
ID: 21772743
rather than writing to the table, you can also create a query that adds the spaces dynamically.

- Create a new query
- Add all the fields that you'd like exported
- replace the field(s) where you need trailing spaces with
     myFld:table.myFld & space(number of spaces)
- export new query

That way you're never writing to your original data
0
 
LVL 44

Expert Comment

by:GRayL
ID: 21772806
morang:  What bmoabc makes a lot of sense. Rather than the update to your table turn the update into a normal select query and export the the query.

bmoabc:  morang had accepted a minute before your post arrived.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now