I have a database with multiple tables that share several common fields (ID (Guid), Title, ParentID(Guid)), but any of them can have table specific fields.
Is it possible to create a view that UNIONs on these tables and outputs a forth column that is a JSON representation of key value pairs representing the column name and value of ALL other fields other than the 3 common ones? The value of the field would then be used by a web application. It doesn't have to be JSON, it could be XML, comma separated, but basically should represent the fieldname / value pairing of one or more fields that are not common between the unioned tables.
To Clarify. Take the following two table schemas
Table1
ID Title ParentID ABooleanField AnIntegerField
1 A Parent NULL True 50
2 A Child 1 False 100
Table2
ID Title ParentID ADateField
3 AnotherParent NULL 10/12/2014
The View would then output this as
ID Title ParentID Uncommon
1 A Parent NULL ABooleanField:True,AnIntegerField:50
2 A Child 1 ABooleanField:False,AnIntegerField:100
3 AnotherParent NULL ADateField:10/12/2014
The IDs would be GUIDs in reality and the Uncommon field would be NVARCHAR(MAX)
Cheers
Stewart