473,394 Members | 1,787 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,394 software developers and data experts.

Create delimited file

mshmyob
904 Expert 512MB
I have two tables that are related by a ContactID field that allows each contact to have multiple email addresses (ie: 1:M).

tblContact-> ContactID, ContactFName, ContactLName, ContactCompany, CategoryID
tblContactEmail-> EmailID, ContactID, EmailDesc

I have created a simple Select query like:

Expand|Select|Wrap|Line Numbers
  1. SELECT tblContact.ContactFName, tblContact.ContactLName, tblContact.ContactCompany, tblContactEmail.EmailDesc
  2. FROM tblContact INNER JOIN tblContactEmail ON tblContact.ContactID = tblContactEmail.ContactID
  3. GROUP BY tblContact.ContactFName, tblContact.ContactLName, tblContact.ContactCompany, tblContactEmail.EmailDesc, tblContact.CategoryID
  4. HAVING (((tblContact.CategoryID)=7));
  5.  
The result from this query simply displays all the contact names, company names, and email addresses of all contacts classified as Clients.

Each contact's email is on a seperate line. I however need to combine the email addresses of any contact who has the same ContactID on a single line for export to Outlook address book.

Is there a way to do this in SQL and if so how?

P.S. - I am trying to export the contacts to an Outlook address book but this way creates multple entries for anybody who has more than one email address since I cannot map the field to email address 2 and email address 3 in Outlook but I can if I can get them on one line. Unless someone with better knowledge of Outlook than me has a better way of doing it.

cheers,
Feb 14 '11 #1
2 1469
Lysander
344 Expert 100+
You could write a function, say MakeMail() that accepts the contactId. This function could then loop through tblContactEmail and build up a string of all the email addresses. MakeMail would the return the string of 0, 1 or more email addresses.

Then use MakeMail(contactId) in your query
Feb 14 '11 #2
mshmyob
904 Expert 512MB
Thanks Lysander, I thought there might not be a "pure" SQL approach but I was just checking.

cheers,
Feb 17 '11 #3

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

Similar topics

3
by: monte | last post by:
Hello, I need to parse a tilde delimited file and output it to a tabbed delimited file. Example file example.txt data1~data2~data3~data4 data5~data6~data7~data8 I need to extract data2,...
3
by: Elmo Watson | last post by:
I've been asked to develop a semi-automated type situation where we have a database table (sql server) and periodically, there will be a comma delimited file from which we need to import the data,...
6
by: Skc | last post by:
I am trying to import a file using a custom VB.net procedure, but the problem is it works on a file with pure comma separation and not inverted commas and commas, i.e. it works for AAA,BBB,CCC,DDD...
5
by: Karl Irvin | last post by:
I'm using the Write # statement to create a csv export file from Access 2K Some of the data has embedded quotes in it and it doesn't import into QuickBooks correctly. An inventory part with a...
1
by: j7.henry | last post by:
I am trying to pull specific data that is in a comma delimited file into a web page. So if my comma delimited file looks like: Name,Address,Zip Fred,123 Elm,66666 Mike,23 Jump,11111 I would...
5
by: bebe | last post by:
Hi, How do I write a function in SQL to convert data from a table to a comma delimited text file and get it imported in excel or word? I already have a function that convers data to an xml. but I...
1
jwwicks
by: jwwicks | last post by:
Hello All, This is a student assignment. So I don't want the complete answer just a hint or maybe a bumb on the head cause I'm doing it the wrong way. Assume I haven't done anything braindead like...
0
by: Kristi | last post by:
I need to create a CL program that will take a PF, and create a tab delimited file that has comma seperated column headings as the first record. I know i can use cpytostmf/cpytoimpf to create the...
11
by: kimmelsd33 | last post by:
I would like some expert advice. I am writing in VB6. I am opening a tab delimited file, deleting the first 50 lines, and rewriting the file to a temp file. The temp file has about 20 columns with x...
7
by: kimmelsd33 | last post by:
I am using VB6. I want to read a tab delimited file, and assign each column value into a variable. If the variable is "-999.25", I want to make it a "0". I then want to reassemble the values, and...
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
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...
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...
0
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...

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.