Solved

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

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
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.

776 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