Solved

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

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

[Webinar] Disaster Recovery and Cloud Management

Learn from Unigma and CloudBerry industry veterans which providers are best for certain use cases and how to lower cloud costs, how to grow your Managed Services practice in IaaS clouds, and how to utilize public cloud for Disaster Recovery

Question has a verified solution.

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

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

863 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

23 Experts available now in Live!

Get 1:1 Help Now