CloudApps
asked on
SQL Server 2008 R2 Related Function
I have a table named WellDocuments with a WellID, DocumentTypeID and WellDocument fields.
I have another table named DocumentTypes with a DocumentTypeID, DocumentType and SortOrder fields.
The tables are related using the DocumentTypeID field.
I am trying to add a calculated field, SortOrder, to the WellDocuments table to lookup the SortOrder from the DocumentTypes table.
My formula is: =Related('DocumentTypes'[S ortOrder])
I get the message: Error validating the formula for column 'SortOrder'.
Please help.
Thanks,
I have another table named DocumentTypes with a DocumentTypeID, DocumentType and SortOrder fields.
The tables are related using the DocumentTypeID field.
I am trying to add a calculated field, SortOrder, to the WellDocuments table to lookup the SortOrder from the DocumentTypes table.
My formula is: =Related('DocumentTypes'[S
I get the message: Error validating the formula for column 'SortOrder'.
Please help.
Thanks,
ASKER
I need to use the modified WellDocuments table as the datasource for webpages that allows records to be added, edited and deleted. I did try using a view, but it was not updateable, unless I missed something in that regard.
Thanks,
Thanks,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I was on the wrong track with the "Related" function.
I built a view with a subquery as the SortOrder. The view is now updatable.
SELECT WellID, WellDocumentID, DocumentTypeID, WellDocument,
(SELECT SortOrder
FROM dbo.DocumentTypes AS T2
WHERE (DocumentTypeID = T1.DocumentTypeID)) AS SortOrder
FROM dbo.WellDocuments AS T1
Thanks,
I built a view with a subquery as the SortOrder. The view is now updatable.
SELECT WellID, WellDocumentID, DocumentTypeID, WellDocument,
(SELECT SortOrder
FROM dbo.DocumentTypes AS T2
WHERE (DocumentTypeID = T1.DocumentTypeID)) AS SortOrder
FROM dbo.WellDocuments AS T1
Thanks,
Select WellDocuments.*, DocumentTypes.SortOrder
From WellDocuments
Inner Join DocumentTypes on WellDocuments.DocumentType
That should give you the WellDocuments table along with the SortOrder field from DocumentTypes.
Is this not what you're trying to do?