[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 407
  • Last Modified:

Combine SQL Tables

Hi,
I have a database collecting the event logs from my server, I need to be able to build a front end to view it, but I think the first thing I need to do is build a view that combines the 3 tables. All of the columns are exactly the same, for instance ComputerName, and Message. The 3 tables are dbo.Application, Dbo.Security, and dbo.System. How do I build a view that combines them together?
0
141ANG
Asked:
141ANG
  • 2
  • 2
1 Solution
 
cyberkiwiCommented:
UNION them together, and have a made up column to denote the source of the data

select 'Application' EventSource, ComputerName, Message, EventTime
from dbo.Application
union all
select 'Security' EventSource, ComputerName, Message, EventTime
from dbo.Security
union all
select 'System' EventSource, ComputerName, Message, EventTime
from dbo.System

Open in new window

0
 
cyberkiwiCommented:
Create a view out of that query..

CREATE VIEW CombinedEventLog
AS
select 'Application' EventSource, ComputerName, Message, EventTime
from dbo.Application
union all
select 'Security' EventSource, ComputerName, Message, EventTime
from dbo.Security
union all
select 'System' EventSource, ComputerName, Message, EventTime
from dbo.System

Open in new window

0
 
141ANGAuthor Commented:
perfect, now I just have to figure out how in the world I am going to build a front end for it, lol.
0
 
Alpesh PatelAssistant ConsultantCommented:
Select * from table1
union all
Select * from table2
union all
Select * from table3
0
 
141ANGAuthor Commented:
Perfect, Thank you!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now