StuartBombay
Programmer
This may have been the wrong way to go about this, but here is what I've already done.
I have a database that tracks support tickets. There is an incident table and other tables for notes, assignments, reminders, etc. that are stored in other related tables. In order to see these entries in chronological order on a Crystal Report I created a view that uses a series of UNION ALL statements. Here is a chunk of it:
It goes on and on from there.
I need a primary key in here. Is there a way I can have the 'IncidentGUID' column be a key? There will be duplicates in there, but can it still be a key or would I create a new column that would generate a unique number?
Or, perhaps there is a better way to do this (other than a view)?
I have a database that tracks support tickets. There is an incident table and other tables for notes, assignments, reminders, etc. that are stored in other related tables. In order to see these entries in chronological order on a Crystal Report I created a view that uses a series of UNION ALL statements. Here is a chunk of it:
Code:
CREATE VIEW [dbo].[IncidentNotes]
AS
[green]--Get Incident[/green]
SELECT
process.guid AS [red]'IncidentGUID'[/red],
process.title AS [red]'Title'[/red],
process.description AS [red]'Text'[/red],
process.creator AS [red]'AnalystGUID'[/red],
process.create_date AS [red]'Date'[/red],
'Incident Creation' AS [red]NoteType[/red],
user.name AS [red]'Analyst[/red]'
FROM pm_process INNER JOIN tps_user ON process.creator = user.guid
--Incident Note
UNION ALL
SELECT
incident_note.incident_guid AS [red]'IncidentGUID'[/red],
incident_note.title AS [red]'Title'[/red],
incident_note.text AS [red]'Text'[/red],
incident_note.update_user_guid AS [red]'AnalystGUID'[/red],
incident_note.update AS [red]'Date'[/red],
'Incident Note' AS [red]NoteType[/red],
user.name AS [red]'Analyst'[/red]
FROM ' incident_note INNER JOIN user ON incident_note.last_update_user_guid = user.guid
--Incident Reopen
UNION ALL
SELECT
incident_reopen.incident_guid AS [red]'IncidentGUID'[/red],
incident_reopen.title AS [red]'Title'[/red],
incident_reopen.description AS [red]'Text'[/red],
incident_reopen.update_user_guid AS [red]'AnalystGUID'[/red],
incident_reopen.update AS [red]'Date'[/red],
'Reopen' AS [red]NoteType[/red],
user.name AS [red]'Analyst'[/red]
FROM incident_reopen INNER JOIN user ON incident_reopen.update_user_guid = user.guid
It goes on and on from there.
I need a primary key in here. Is there a way I can have the 'IncidentGUID' column be a key? There will be duplicates in there, but can it still be a key or would I create a new column that would generate a unique number?
Or, perhaps there is a better way to do this (other than a view)?