Solved

SQL Server Combine TableA with many records with TableB with one record and no common field.

Posted on 2013-01-22
5
469 Views
Last Modified: 2013-01-23
I have an email list table that I want to merge with a table containing email body content text.  How do I associate every record in the email list with the email body content record?

TableA contains 3 records first row is column name:
EMail                    FirstName        LastName
JoesEmail             Joe                     Smith
AnnsEmail            Ann                    Jones
MikesEmail          Mike                   Davidson

TableB contains 1 record first row is column name:
Information1          Information2                   Information3
Info1Text                Info2Text                         Info3Text


Desired output:
JoesEmail              Joe                Smith          Info1Text            Info2Text             Info3Text
AnnsEmail             Ann               Jones          Info1Text            Info2Text             Info3Text
MikesEmail           Mike             Davidson     Info1Text            Info2text             Info3Text
0
Comment
Question by:lotterygirl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 11

Expert Comment

by:Guru Ji
ID: 38807745
There is a simple statement for that

Select * from TableA, TableB

This will show you your desired output
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 38807748
There may be a difference in what you actually asked for and what you really need, but this is it.  :)

select A.EMail, A.FirstName, A.LastName, B.Information1, B.Information2, B.Information3
from TableA
join TableB
on 1=1
0
 
LVL 69

Accepted Solution

by:
Scott Pletcher earned 500 total points
ID: 38807863
The above methods are technically obsolete.

The formal/ANSI term is "CROSS JOIN", like so:

SELECT A.*, B.*
FROM dbo.TableA
CROSS JOIN dbo.TableB

Note that "CROSS JOIN" doesn't allow an "ON" clause, since by definition a CJ joins every row from the left table to every row in the right table.
0
 
LVL 24

Expert Comment

by:DBAduck - Ben Miller
ID: 38809908
Yes, CROSS JOIN is the way to accomplish this in a non-obsolete way.
0
 

Author Closing Comment

by:lotterygirl
ID: 38809984
That is what I needed.  Thanks.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

729 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