473,809 Members | 2,772 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

select...outfil e...fixed length?

I have query that I export into a file using the "outfile" syntax. I can
use the following lines of code to create a delimited file but I want to
know if I can create a fixed length file? Any ideas?

delimited file:
Select GivenName, Surname, Address, City, State, ZipCode
into outfile 'xx.csv' fields terminated by ',' lines terminated by '\r\n'
from kbm
where zipcode = '12345'

TIA
-bruce duncan

Jul 23 '05 #1
2 3054
"Bruce D" <br************ *@hotmail.com> wrote in message
news:10******** *****@corp.supe rnews.com...
I have query that I export into a file using the "outfile" syntax. I can
use the following lines of code to create a delimited file but I want to
know if I can create a fixed length file? Any ideas?

delimited file:
Select GivenName, Surname, Address, City, State, ZipCode
into outfile 'xx.csv' fields terminated by ',' lines terminated by '\r\n'
from kbm
where zipcode = '12345'

TIA
-bruce duncan


I figured out a way...but it's not perfect because I have to define the
length...is there a way so that I don't have to use rpad()?

Use rpad().
Select rpad(GivenName, 15,' '), rpad(Surname,15 ,' '), rpad(Address,25 ,' ')
into outfile 'xx.csv' fields terminated by ',' lines terminated by '\r\n'
from kbm
where zipcode = '12345'

-bruce duncan
Jul 23 '05 #2
> I figured out a way...but it's not perfect because I have to define the
length...is there a way so that I don't have to use rpad()?

Use rpad().
Select rpad(GivenName, 15,' '), rpad(Surname,15 ,' '), rpad(Address,25 ,' ')
into outfile 'xx.csv' fields terminated by ',' lines terminated by '\r\n'
from kbm
where zipcode = '12345'

-bruce duncan


Now I got it...if I just use "fields terminated by ''" it works just fine.
That was easy....
-bruce
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1477
by: Thompson, Jordan | last post by:
I wan to use a variable for the outfile file name in a select into clause. I am doing something like: set @fileName="/tmp/result.text" SELECT col1, col2 INTO OUTFILE @fileName FIELDS TERMINATED BY ',' FROM test_table; the interpreter dies at the @fileName... if I exchange @filename with "/tmp/result.text" it runs fine.
1
3276
by: Tom Pope | last post by:
Is there a way to have the field descriptions put into an outfile? When I do a Select * from data, the display shows the field names, however when I do the select * into outfile /tmp/test.txt the field names are not in the file. Thanks for the help Tom
3
2410
by: Michael Qiu | last post by:
I hava a select component on my form. the width of the select component is fixed,so if the length of the option's shown string larger than the select component's width,how can i make the shown string wrap to next line? <select name=123 style="width:100px;height:200px"> <option value=1>abcdefghijklmnopqrstuvwxyz</option> </select> select component's width is 100px, the option's shown sring is abcdefghijklmnopqrstuvwxyz,if shown string's...
2
3489
by: mark4asp | last post by:
Why does this not work in Mozilla ? <http://homepage.ntlworld.com/mark.pawelek/code/animals.html> The optHabitat_change() event does not fire. What am I doing wrong here? PS: It should repopulate the 2nd combo based upon the value of the selected item in the first, just like it does in IE.
8
11117
by: Rich | last post by:
My table looks like this: char(150) HTTP_REF, char(250) HTTP_USER, char(150) REMOTE_ADDR, char(150) REMOTE_HOST, char(150) URL, smalldatetime TIME_STAMP There are no indexes on this table and there are only 293,658 records total.
0
3912
by: Wamaniyma Akolwa | last post by:
Hi I am running MYSQL 5.0 ON WINXP pro. I have the following procedure: DELIMITER $$ DROP PROCEDURE IF EXISTS LSMW_COST_SWITCH $$ CREATE PROCEDURE LSMW_COST_SWITCH() BEGIN
2
5227
by: varusnyc | last post by:
Hello, Im having really hard time writing an Employee Payroll program that uses functions to read data from file then send all data to another file. I managed to construct some pieces of the code, but I cant figure out how to put it together. Here's the description of whats needed to be done: Write a program that generates an Employee Payroll. All output should go to payroll.out. The input for the program should be read from a file,...
3
2927
by: matwilko | last post by:
hi, i am trying to create a simple version of itunes...and i am using iframes to do this. I have already set up the iframes using dreamweaver and used a drop-down menu to select the genre. When selecting the genre the artists appears in iframe1...and i want to be able to select the artist so that the songs appear. I am unsure of how to do this, could anybody help? Thanks Here is my current code... <html> <head> <title>MiTunes</title>...
2
4324
by: Nikhil | last post by:
I am using the MySQLdb python module. I have a table named 'testing' with few columns, under the 'test' database, what is hosted on a remote mysql server. I want to run the following query to get a comma-seperated information from the table LOCK TABLES foo READ; SELECT a,b,a+b INTO OUTFILE '/tmp/result.txt'
0
9601
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10637
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10115
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9199
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.