• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 427
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

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