Answered by:
How to get sharepoint document library metadata details from sql?

Question
-
I am creating a windows form application , in which user selects document library and after clicking on button I am creating an excel file which displays all document name with its metadata information.
The select query which I am querying to SQL Server is:
DECLARE @listId AS UNIQUEIDENTIFIER = 'c8508816-a7fb-43f1-82d1-62d79cbaf8e6'; DECLARE @fileNameFilter AS VARCHAR (250) = NULL; DECLARE @dirFilter AS VARCHAR (250) = NULL; SELECT DISTINCT d.Id AS 'FileId', d.WebId AS 'WebId', d.SiteId AS 'SiteId', d.DirName AS 'DirName', d.LeafName AS 'FileName', ISNULL(d.Size,0) AS 'Size', d.UIVersion AS 'UIVersion', ISNULL(d.InternalVersion,0) AS 'InternalVersion', ISNULL(d.ETagVersion,0) AS 'ETagVersion', d.Type as 'Type', aud.tp_Created AS 'Created', ui.tp_Login AS 'CreatedBy' FROM AllDocs AS d INNER JOIN AllUserData AS aud ON d.Id = aud.tp_DocId INNER JOIN UserInfo AS ui ON aud.tp_Author = ui.tp_ID WHERE d.ListId = @listId AND (@fileNameFilter IS NULL OR d.LeafName LIKE '%' + @fileNameFilter + '%') AND (@dirFilter IS NULL OR d.DirName LIKE '%' + @dirFilter + '%');
By using this query I am able to get the file name, its directory name, version but I want to fetch all data like custom fields with this query. I don't know which table to query for custom fields and content type fields.
Please help.
- Edited by Mohemmad K Monday, March 24, 2014 5:13 AM
Monday, March 24, 2014 5:12 AM
Answers
-
Hello,
MS never suggest to query content database directly. If you do this then you are on risk and can face performance issue.
if you really wants to get document name and it's metadata then use lists.asmx in windows application. This is standard way to get data from site.
http://msdn.microsoft.com/en-us/library/dd490727%28v=office.12%29.aspx
Hope it could help
Hemendra:Yesterday is just a memory,Tomorrow we may never see
Please remember to mark the replies as answers if they help and unmark them if they provide no help- Proposed as answer by Inderjeet Singh Jaggi Thursday, March 27, 2014 12:46 PM
- Marked as answer by Hemendra AgrawalModerator Tuesday, April 8, 2014 8:42 AM
Thursday, March 27, 2014 12:08 PMModerator
All replies
-
The column fields are stored in the AllUserData table in the tp_ColumnSet Column as xml.Thursday, March 27, 2014 2:02 AM
-
Hello,
MS never suggest to query content database directly. If you do this then you are on risk and can face performance issue.
if you really wants to get document name and it's metadata then use lists.asmx in windows application. This is standard way to get data from site.
http://msdn.microsoft.com/en-us/library/dd490727%28v=office.12%29.aspx
Hope it could help
Hemendra:Yesterday is just a memory,Tomorrow we may never see
Please remember to mark the replies as answers if they help and unmark them if they provide no help- Proposed as answer by Inderjeet Singh Jaggi Thursday, March 27, 2014 12:46 PM
- Marked as answer by Hemendra AgrawalModerator Tuesday, April 8, 2014 8:42 AM
Thursday, March 27, 2014 12:08 PMModerator