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
Solved

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

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
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

809 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