There are multiple ways to retrieve this information:
- Using MOSS 2007 API
- Via Versions.asmx - An OOB SharePoint Webservice
- Or Querying the Docs & DocVersions table directly in using T-SQL statements
SPWeb web = new SPSite("your site url").OpenWeb();
SPList lib = web.Lists["your library"];
foreach (SPListItem item in lib.Items)
SPFileVersionCollection versions = file.Versions;
//Add your code to loop through the version collection & add custom logic here..
Coming to WebService approach:
SharePoint has a Versions.asmx web service to work with versions in document libraries.
For introduction, check out how to utilize this to get some information :
Incase, you want to go ahead querying the SQL tables directly, then you could try a query as below:
FROM Docs INNER JOIN DocVersions ON DocVersions.Id = Docs.Id
Although it is not recommended that you query the SP DB directly. Any modifications or changes to the Content DB tables in unsupported.
Also the data is stored in UTF-8 Encoded format. After the query runs, it returns some data like this:
The above data is difficult to interpret in terms of Version numbers. Anyway, just to let you know
512 = version 1,
1024 =version 2,
2048= version 3,
and so on..
I guess the pattern is clear to you. Hope this article helps you.