Solved

SQL: Create Table

Posted on 2011-03-01
2
273 Views
Last Modified: 2012-05-11
Need to LEFT OUTER JOIN to an imaginary table that I need to create on the fly...kind of like an array.

I attached an Excel sheet of what I need to LEFT OUTER JOIN to.

SELECT R.DisplayName, E.Entered
FROM Resources R LEFT OUTER JOIN ( EXCEL SHEET ) E ON E.RsrcNo = R.RsrcNo
Book1.xlsx
0
Comment
Question by:InfoTechEE
2 Comments
 
LVL 75

Assisted Solution

by:Aneesh Retnakaran
Aneesh Retnakaran earned 250 total points
ID: 35013651
0
 
LVL 32

Accepted Solution

by:
ewangoya earned 250 total points
ID: 35013653
Use a temp table
declare @Table1 Table(RsrcNo int, DisplayName varchar(20), Entered datetime)

insert into @Table1
select 1743, 'User 1', '6/6/2006'
union all
select 4986, 'User 2', '5/4/2010'
union all
select 1672, 'User 3', '8/18/2006'
union all
select 5100, 'User 4', '3/1/2011'
union all
select 1821, 'User 5', '6/8/2005'
union all
select 4214, 'User 6', '9/25/2006'
union all
select 3623, 'User 7', '4/19/2006'
union all
select 4089, 'User 8', '8/18/2006'

SELECT R.DisplayName, E.Entered
FROM Resources R 
LEFT OUTER JOIN @Table1 E ON E.RsrcNo = R.RsrcNo

Open in new window

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

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.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how the fundamental information of how to create a table.

777 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