I want to query the Final renderings fields for an item in Sitecore directly against the database to check if they have ever had values. I have created the following query but want to be sure it's correct:
SELECT TOP 1 [Id],
[ItemId],
[FieldId],
[Value],
[Created],
[Updated],
[DAC_Index]
FROM [VersionedFields]
WHERE fieldid = '04BF00DB-F5FB-41F7-8AB7-22408372A981'
AND ItemId = '947EBF93-E9F2-4C12-8BC3-78B75B595428'
My query doesn't return any results for this item but I'm assuming this is because it has never had any renderings added to the page or edited and it is just using the renderings set on the standard values of my page template.
Also I would like to do a similar query for the renderings field but I don't get any results for this either so wanted to be sure this query is also right:
SELECT TOP 1 f.[Id],
[ItemId],
[FieldId],
[Value],
f.[Created],
f.[Updated],
f.[DAC_Index],
i.Name
FROM [SharedFields] f
INNER JOIN [Items] i ON f.itemid = i.id
WHERE fieldid = 'F1A1FE9E-A60C-4DDB-A3A0-BB5B29FE732E'
AND ItemId = '947EBF93-E9F2-4C12-8BC3-78B75B595428'
I'm doing these queries as I want to see if my page item has ever had any renderings set in experience editor in the database backups I have - or if it just has the values from standard values and it's never been updated.
Further Information: Sitecore 8.1 update 2
To be clear the question I need to answer is: do these queries confirm my page has never had any updates to the renderings?
INNER JOIN
on your second example?[SharedFields]
holds both the FieldId and ItemId you would require.