How to get sharepoint document library metadata details from sql?

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.

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

Similar Messages

  • How to connect SharePoint Document Library with Local file system?

    Hi
    I have a SharePoint Document library and in my local system i have 3TB files. It is very difficult to upload 3TB files in SharePoint.
    I want a file details in SharePoint Document Library but physical file would be in local.
    While click the file in Document library. The document should open from local.
    Anyone help me on it.
    Thanks & Regards
    Poomani Sankaran

    Hi,
    your requirement doesn't work out-of-the-box as all data uploaded to SharePoint needs to be stored in SQL database. Thus in your case 3 TB of fileshare would need to move to SQL.
    In case you don't want to go this way, there are 3rd party vendors who offer Software like AvePoint Connector. Products like these use SQL RBS (Storage Externalization API) so that files remain in your file system but metadata is kept in SharePoint. If you
    need more information on that, please let me know.
    Regards,
    Dennis

  • How to backup SharePoint Document Library

    I have SharePoint 2010 And I have used it as document management system, I wandered if make backup to SharePoint database is enough to backup our documents in another word Documents is stored in SharePoint database, please advise. 

    You're asking a good question, but the problem is that its one that can take a
    great deal of time to answer in depth. I'll try to cover the broad strokes here...
    Yes, backing up your SharePoint content databases will technically create a backup of the documents that you are uploading into the SharePoint sites stored in those content databases.
    BUT , there's a lot more to consider than just that. The bullet points below cover some of the big ones off the top of my head:
    SharePoint stores documents in its content databases using the Binary Large Object (BLOB) data type. It is not possible to directly extract a document from a SharePoint database without going through SharePoint, at least not in a manner supported by MS.
    This means that you must re-attach the restored content database to a live SharePoint farm in order to get to those documents again once you've restored the database from backup.
    And that means that you'll have to rebuild an entire farm and reattach that database to it, not something that can usually be done quickly.
    In order to reattach that database backup to a SharePoint farm, your new farm must be patched to at least the same version as the farm where the content database originated. So you have to be careful to track the version of SharePoint you used in the farm
    and rebuild to that level.
    If the site collections in that content database used any custom code, site templates, web parts, etc, you must install those into your new farm, or there's a good chance your site's won't work and you won't be able to access your content.
    You'll have to re-do all of the configuration settings you customized in your new farm as well, if you want it to be able to replace the functionality of your current farm. SharePoint 2010 does introduce configuration database backups, but they're not a
    complete solution (they don't include ALL of the configuration data for your farm).
    Changes to the configuration of your sites in IIS, files in the SharePoint root directories, Active Directory, etc, are not captured in SQL Server or SharePoint backups. You'll need to back them up yourself.
    I will qualify my comments by saying that I'm talking about this stuff from an overall Disaster Recovery perspective, not from a targeted approach to protect some specific highly important documents you're putting into SharePoint. But this is all stuff you
    have to consider if you're going to use SQL Server to protect those documents.
    I would recommend also taking a look at SharePoint's ability to save a document library or list as a template with content included, this can allow end users to save content on their own through the SharePoint site's UI and protect it. Or, you can use the
    Export-SPWeb PowerShell CMDLET (http://technet.microsoft.com/en-us/library/ee428301.aspx ) to script out the protection of that document library as well.
    Does that all make sense?
    John
    MCTS: WSS v3, MOSS 2007, and SCOM 2007
    MCITP: Enterprise Project Management with Project Server 2007
    Now Available on Amazon - The SharePoint 2010 Disaster Recovery Guide. Also available -
    The SharePoint 2007 Disaster Recovery Guide.
    My blog: My Central Admin.

  • How to get Week,Month and Year details from a date column

    Hi frenz,
    I've a column like tran_date which is a date column..... I need the next week details based on this column and so on...
    I need month and year details as well based on this tran_date column.... can any one tell me how...
    Thanks in advance

    My example for objects:
    create or replace type date_object as object
      centure number,
      year    number,
      month   number,
      day     number,
      hour    number,
      minute  number,
      second  number,
      daypart number,
      week    number,
      constructor function date_object(p_dt date)
        return SELF as result
    create or replace type body date_object is
      constructor function date_object(p_dt date)
        return SELF as result
      as
      begin
        SELF.centure:= trunc(to_char(p_dt,'YYYY')/100);
        SELF.year:=    to_char(p_dt,'YYYY');
        SELF.month:=   to_char(p_dt,'MM');
        SELF.day:=     to_char(p_dt,'DD');
        SELF.hour:=    to_char(p_dt,'HH24');
        SELF.minute:=  to_char(p_dt,'MI');
        SELF.second:=  to_char(p_dt,'SS');
        SELF.daypart:= p_dt-trunc(p_dt,'DD');
        SELF.week:=    to_char(p_dt,'IW');
        return;
      end;
    end;
    select date_object(sysdate),
           date_object(sysdate).year
    from dual;Regards,
    Sayan M.

  • How to get all available VM OS details from my Hyper-v-host?

    HI,
    I have one VM Server in my windows 8 machine, in that I have 2 vm'. Now I want to find alll vm's os detials?
    Thanks in advance.
    A Pathfinder.
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful"
    Best Online Journal

    or 
    get-vm LapVM1 | select *
    Read more at:
    Hyper-V Cmdlets
    Mike Crowley | MVP
    My Blog --
    Planet Technologies

  • How to find Down Payment document with vendor details from AW01N

    Hi,
    I am trying to do partial settlement in KO88, for AUC to Fixed Asset. While running the T Code I am getting the following error message.
    Down payment to recipient 100620 0 area 01 amount   13,181,454.04 not cleared
    Message no. AW605
    I went through many threads for this issue and I am trying to clear the downpayment in F-54. But I am not able to find the Vendor details to whom the Down Payment was done, neither the dosument number against which the downpayment has to be cleared.
    I tried finding these details in AW01N. I could find the amount reflecting in the Planned and Posted tab in the first section.
    But was not succesful to find the documents and vendor details from there.
    In the second section in Planned Tab, I am finding some transactions. There I am finding Down Payment mentioned. When I double click on Down Payment in AW01N, I am taken to the document which is a clearing of Down Payment. You can see the below entry.
    81008100
    Fixed Assets Interim
    1,049,371.84-
    30300100
    000000900000 0000
    2,538,367.44
    30520000
    Clg Cap D-Pmts-T-Ast
    2,538,367.44-
    30300100
    000000900000 0000
    1,049,371.84
    30300100
    000000900000 0000
    101,948.00-
    30520000
    Clg Cap D-Pmts-T-Ast
    101,948.00
    Now, how do I know which documents to be cleared to which Invoice and the vendor details.
    Kindly help me with this issue.

    Hi,
    Thanks. Kindly suggest now, how to find the documents and vendor details from there.
    When I double click on any Down Payment in AW01N, I am taken to the document which is a clearing of Down Payment. You can see the below entry.
    81008100
    Fixed Assets Interim
    1,049,371.84-
    30300100
    000000900000 0000
    2,538,367.44
    30520000
    Clg Cap D-Pmts-T-Ast
    2,538,367.44-
    30300100
    000000900000 0000
    1,049,371.84
    30300100
    000000900000 0000
    101,948.00-
    30520000
    Clg Cap D-Pmts-T-Ast
    101,948.00
    Now, I want to clear the down payments in F-54, but how do I know which documents needs to be cleared to which Invoice and the vendor details. Since I am getting error while executing KO88 AUC transfer to Assets.
    Down payment to recipient 100620 0 area 01 amount   12,832,161.41 not cleared
    Message no. AW605
    Diagnosis
    All downpayments were not cleared for the asset under construction for the receiver 100620 0 in area 01. An amount of   12,832,161.41 was not cleared, or too much was cleared.
    You can only completely transfer an asset under construction if you reverse the down payments in the current fiscal year beforehand.
    Procedure
    Clear the downpayments that you want to settle to receiver 100620 0.
    Check screen shot.

  • How to grant anonymous access on sharepoint document library/list only not for web application

    Hello
    How to grant anonymous access on sharepoint document library/list only not for web application.I have claim based sharepoint site and has to be but i want to grant access on document library/list only.Is this possible?
    Thanks
    Rajesh Kumar "Changing the Face" can change nothing.But "Facing the Change" can change everything.

    As i am using following code
    SPSite site = SPContext.Current.Site;
                SPWeb web = SPContext.Current.Web;
                SPSecurity.RunWithElevatedPrivileges(delegate()
                    using (SPSite ospSite = new SPSite(site.ID))
                        using (SPWeb webs = ospSite.OpenWeb(web.ID))
                            // Enable anonymous access on web application
                            webs.AllowUnsafeUpdates = true;
                            SPUrlZone urlZone = SPUrlZone.Default;
                            SPWebApplication specifiedWebApplication = ospSite.WebApplication;
                            SPIisSettings iisSettings = specifiedWebApplication.IisSettings[urlZone];
                            //iisSettings.AuthenticationMode = AuthenticationMode.Windows;
                            iisSettings.AllowAnonymous = true;                       
                            specifiedWebApplication.Update();
                            // Get document library collection here and fetch all the document urls
                            SPDocumentLibrary docLib = (SPDocumentLibrary)web.Lists["Documents"];
                            if (docLib != null)
                                docLib.BreakRoleInheritance(true, false);
                                docLib.AllowEveryoneViewItems = true;
                                docLib.AnonymousPermMask64 = SPBasePermissions.ViewPages | SPBasePermissions.OpenItems | SPBasePermissions.ViewVersions
                                    | SPBasePermissions.Open | SPBasePermissions.UseClientIntegration | SPBasePermissions.ViewFormPages | SPBasePermissions.ViewListItems;
                                //docLib.AnonymousPermMask64 = SPBasePermissions.EmptyMask;
                                docLib.Update();
    Should working but getting access denied......i am totally stuck at this point.
    Rajesh Kumar "Changing the Face" can change nothing.But "Facing the Change" can change everything.

  • How to upload email from outlook to a sharepoint document library programatically.

    Hi ,
    I have a requirement where I need to create a outlook plugin which will upload selected emails to sharepoint document library. I am able to hold email using by creating the object of outlook.item.  but could n't find a way to upload created com object
    in to sharepoint library.
    I need to use webservice to upload email to the document library.
    can some one please help me with this?
    Thanks.

    Hi,
    Base on the description, you want to upload email from outlook to a sharepoint document library programatically.
    We need to do it using Web Services, there's a purpose built web service here http://cecildt.blogspot.com/2010/10/upload-documents-to-sharepoint-2010.html‎
    for uploading documents.
    The other alternative is using email enabled document libraries
    https://www.nothingbutsharepoint.com/sites/itpro/pages/how-to-setup-mail-enabled-document-libraries-in-sharepoint-2010-part-4.aspx
    Best Regards,
    Linda
    Li

  • How to rename the SharePoint Document Library existing file name using Web service

    Hi,
    How to rename the SharePoint Document Library existing file name using SharePoint Web service.
    Is it possible. How could i do it?
    Thanks & Regards
    Poomani Sankaran

    Hi,
    Lists.UpdateListItems Method
    would be helpful for your requirement.
    Here is a blog with code demo for your reference:
    http://blogs.msdn.com/b/knowledgecast/archive/2009/05/20/moss-using-the-list-web-service-to-rename-a-file.aspx
    Best regards,
    Patrick
    Patrick Liang
    TechNet Community Support

  • How to display the thumbnail view of the documents in Sharepoint Document Library

    Is there a way that we can have the thumbnail view of the documents that are uploaded in SharePoint Document Library. We have thumbnail feature in Picture Library but can we have the same in Document Library too. Documents includes Words,Excel,PDF.
    Any Suggestions Please 

    Hey Mike,
    Good post, I'd be curious to see if anyone has used the GD Picture SDK with SharePoint, maybe there would be some sample code.
    Hey Kukdai,
    Developing your own solution would potentially provide a better way to accomplish your task, but before setting out on that long road you may want to try the simple customization, it's less time consuming and it will help gauge your customer's interest and
    support.
    Also, there is a wealth of open source code for SharePoint available on CodePlex, you might want to check that out as well.  Here is the linK:
    http://www.codeplex.com/
    Also, here is an interesting project to consider for your task:
    http://enhancedpicture.codeplex.com/
    I hope that helps!
    Tom Molskow SharePoint Architect - If I solved the issue please propose my reply as the answer - Thanks!

  • Attaching Attributes to Image For Loading to SharePoint Document Library

    We currently have a need to create a searchable document library which will consist solely of images. The standard metadata for a file/image won't suffice in this case. We have some custom attributes that will need to be searchable.
    Essentially, we will have a library of receipt images for expense reporting purposes. We get these images from a third party who handles all of our expense reporting. There are two large zipped files we receive: one file contains all the actual expense report
    "data" that was processed that day(amount, date, client, job, etc.) and the second file contains all the receipt images for those expense report items. Each data file contains data for individual expense reports, and each expense report is assigned
    a unique ID. Each line item in an expense report is also assigned a unique ID. Lastly, each receipt image for a line item of a specific expense report is also assigned a unique ID.
    The zipped image file only contains images. There is a main image file - this contains several smaller zipped files. Each of the smaller zipped files contains all receipt images for a specific expense report. Each image file name is comprosed of three parts:
    The expense report identifier, the unique image identifier, and the expense report line item identifier.
    So, to put this all into perspective:
    On Thursday, we received an image file named extract_images_p006320452r3_20140904171423
    This file contained images for the following unique expense reports:
    The compressed file 95FB8C488519427793FC contains the following receipt images:
    The "data" file - as mentioned before - contains the actual info about the expense and image. These include: date of transaction, date approved, vendor, amount. GL code, type, function, client, project, billable or not, and several other attributes.
    All of this information - including the location of the images - is stored in a SQL Server database and then placed in an SSAS cube.
    The images are related back to the underlying data via the expense report id, and line item id.
    What I need to be able to do is to somehow "tag" these images with all their underlying attributes, load then into a SharePoint document library, and make them searchable.
    I have already figured out that I would need to create several SharePoint lists based on the available values in my OLAP cube (essentially a dataset each for clients, vendors, etc.). The part I have no idea how to accomplish is how to tag each image with
    its respective information.
    All the pertinent info is stored in the database tables, just don't know how to attach it to each image.
    Hopefully, this made some kind of sense. If anyone has any idea on how to even remotely accomplish such a thing, your input would be greatly appreciated!
    Thanks in advance!
    A. M. Robinson

    You will have to develop a custom solution to do this. I am assuming you have taken the first steps to define separate document libraries for the expense reports and images along with site columns and contenttypes. You would define the site columns based
    on the data you want to search on and assign these to corresponding contenttypes. So basically a contenttype for expense reports and receipts possibly. You would link the two contenttypes using the expense report id.
    Your custom solution would have to break apart the zip files and upload and index (set site column data) for each file. Then the user could search on the expense report id and get all the files associated with the expense report.
    An alternative could be to use one document library and have all the files uploaded into their own document set (folder).
    Blog | SharePoint Field Notes Dev Tools |
    SPFastDeploy | SPRemoteAPIExplorer

  • Download older version of a file from SharePoint Document Library using CSOM and 404 error

    Hi,
    I am trying to download previous versions including Major and Minor versions of documents from SharePoint Online using CSOM. I get 404 error when I try to download the file. I found several posts on various discussion forums where people are getting same
    error but none of those have any solution/answer. Below is one of the threads and sample code I have tried that results in 404 error. If I use the link in browser directly, I am able to download the file. Also I am able to download the current version of file
    using CSOM without any problem, it is only the older versions that give me 404 in CSOM.
    http://qandasys.info/how-to-download-the-historical-file-version-content-using-csom/
    public int GetStreamFromFile(string docid, string lib, string fileurl, ClientContext clientContext, int iuserid, string Version, bool isCurrrent)
    if(!isCurrent)
    List LibraryName = clientContext.Web.Lists.GetByTitle(lib);
    clientContext.Load(LibraryName);
    clientContext.ExecuteQuery();
    CamlQuery camlQuery = new CamlQuery();
    camlQuery.ViewXml = "" + fileurl +
    Microsoft.SharePoint.Client.ListItemCollection collListItem = LibraryName.GetItems(camlQuery);
    clientContext.Load(collListItem, items => items.Include(item => item.Id, item => item["FileLeafRef"], item => item["LinkFilename"],
    item => item["FileRef"], item => item["File_x0020_Size"], item => item["DocIcon"], item => item.File.Versions));
    //clientContext.Load(collListItem);
    clientContext.ExecuteQuery();
    foreach (Microsoft.SharePoint.Client.ListItem oListItem in collListItem)
    //string fileurl1 = (string)oListItem["FileRef"];
    //string filename = (string)oListItem["LinkFilename"];
    foreach (FileVersion version in oListItem.File.Versions)
    if (Version == version.VersionLabel)
    //Added excutequery to get object one more time as per blog
    //http://social.technet.microsoft.com/Forums/de-DE/sharepointdevelopmentprevious/thread/88a05256-8694-4e40-863d-6c77512e079b
    clientContext.ExecuteQuery();
    FileInformation fileInformation = ClientOM.File.OpenBinaryDirect(clientContext,version.Url);
    bytesarr = ReadFully(fileInformation.Stream);
    Darwaish

    Hi,
    According to your description,
    I know you want to get older version of a file from SharePoint Document Library using Client Object Model.
    The following code snippet for your reference:
    public void GetVersions()
    ClientContext clientContext = new ClientContext(“http://SPSite”);
    Web site = clientContext.Web;
    clientContext.Load(site);
    clientContext.ExecuteQuery();
    File file = site.GetFileByServerRelativeUrl(“/Shared Documents/mydocument.doc”);
    clientContext.Load(file);
    clientContext.ExecuteQuery();
    ListItem currentItem = file.ListItemAllFields;
    clientContext.Load(currentItem);
    clientContext.ExecuteQuery();
    FileVersionCollection versions = file.Versions;
    clientContext.Load(versions);
    clientContext.ExecuteQuery();
    if (versions != null)
    foreach(FileVersion _version in versions)
    Console.WriteLine(“Version : {0}”,_version.VersionLabel);
    More information:
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.file.versions.aspx
    Best Regards,
    Dennis Guo

  • Upload a document from a form into a SharePoint document library

    The idea is that I have a form which I want to allow users to upload files into my SharePoint document library. I am just not just what to do after the 'HasFile' Statement. Some small snippets of my code below. I am just not sure how from the fileupload ID
    to get it into my document library. Please provide code.
    <asp:FileUpload ID="FileUpload1" runat="server" />
    <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
    Server side code
    protected void Button1_Click(object sender, EventArgs e)
    if (FileUpload1.HasFile)

    protected
    void
    Button1_Click(object
    sender,
    EventArgs
    e)
       if
    (FileUpload1.HasFile)
            // Assuming you have list current context. Or else get reference to the list instance from the parent SPWeb     var list
    = SPContext.Current.List;
         list.RootFolder.Files.Add(FileUpload1.FileName,
    FileUpload1.FileBytes).Update();

  • Sharepoint document library file name column in content database?

    Hi,
    How to get a sharepoint document library file name column in content database?
    Thanks
    Poomani Sankaran

    You're not supposed to develop any solutions accessing the content database directly. It's not supported. Document Library Filename is stored in LeafName column, table: AllDocs.
    2.2.6.1 AllDocs Table
    This post is my own opinion and does not necessarily reflect the opinion or view of Slalom.

  • In SharePoint Document Library Cut and Paste option not working correctly.

    Hi,
    I have a SharePoint Document Library which has the following.
    Folder1 which contains two files named as a File1 and File2
    Folder1 ------------> File1 & File2
    Folder2 has no files.
    Now i am cut the file "File2" from Folder1 and paste in to Folder2.
    Issue is "File2" not permanently remove from "Folder1". It is retaining in "Folder1" It self.
    Can anyone tell me. What is the issue in it?
    Regards
    Poomani Sankaran

    Hi Poomani,
    According to your description, “File 2” still exists in Folder1 after it is been cut and paste to Folder2.
    Can you provide more details about how you perform the operations?
    I tried to move the file between folders in a library in the two ways below, both work without issue:
    1. “Open with Explorer”: cut and paste the file in the Windows Explorer interface;
    https://support.microsoft.com/kb/2629108?wa=wsignin1.0
    2. In the “Site Content and Structure”, use the “Move…” feature of a library;
    https://support.office.com/en-za/article/Work-with-site-content-and-structure-30fcaad9-02b1-4347-8b03-e1ccc5a4c19f
    Feel free to reply if there any progress.
    Best regards,
    Patrick
    Patrick Liang
    TechNet Community Support

Maybe you are looking for

  • Any standarad badi exits for tranction for bp ie in crm

    any standarad badi exits for chnaging or writing code in sap-crm standard tranction bp(busness patner) tr code is bp

  • Can't drag songs into playlist

    I can't drag songs from my library into one of my playlists. Other playlists are fine - it is just the one that won't take songs. Is there a limit for the number of songs in a playlist?

  • Purchase Order: Owner Field

    Hi All, In the Purchase Order; the field Owner (SAP Business One) is filled in automatically (depedning on the user that is logged in); but still the user can change it. Can we limit the user to change this field? Thanks.

  • Object CL_SWF_XI_MSG_BROKER method CALL_TRANSFORMATION cannot be executed

    Hi all, I am getting error in one of the BPM mapping steps. The error description is as below: Error handling for work item 000000013183 Work item 000000013186: Object CL_SWF_XI_MSG_BROKER method CALL_TRANSFORMATION cannot be executed com/sap/xi/tf/_

  • On my second Air, still having issues with core shut down, can I return?

    I am on my second macbook air 1.6 80 HDD. My first air I had for about 3 weeks. I brought it in to get checked out by a genius because of problems I was having watching video. They said they would replace it just this one time. Now after watching a f