Solved

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

Posted on 2013-01-22
5
448 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
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:
ScottPletcher 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Suggested Solutions

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
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.

758 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