I've got a view that's a union of two tables that have overlapping keys and I want to uniquely identify the rows for later retrieval. How can I add an identity or identifier column to the view rows so I can retrieve the rows later by that value?
A:
Hard to answer without your table definitions to hand. However, could you not create an artificial key on the view e.g:
SELECT 'TABLE1' + CAST(KeyColumn AS VARCHAR) AS 'Key' FROM TABLE1
UNION
SELECT 'TABLE2' + CAST(KeyColumn AS VARCHAR) AS 'Key' FROM TABLE2
Myles J
2010-07-28 23:15:50
A:
I wound up using a uniqueIdentifier field defaulted to NewID() and then populated the archive and current tables with GUIDs.
Caveatrob
2010-08-18 02:06:42