Samstag, 17. Dezember 2011

SQL Server 2012 File Tables feature and the benefit with SharePoint

SQL Server 2012 comes with an amazing new feature called “File Tables”.

That means that you can use a file system folder as a database table with all the fun and of cause nearly all the function of a database table. You have to enable the prerequisites for FileTable (as described here: LINK) and the result is a new table in your database with the following propertys:

The columns are fixed and base on the property coming from the NTFS file system. The columns are:
Column Name
Data Type
stream_id
uniqueidentifier ROWGUIDCOL
file_stream
varbinary(max) FILESTREAM
name
nvarchar(255)
path_locator
hierarchyid
creation_time
datetimeoffset(7)
last_write_time
datetimeoffset(7)
last_access_time
datetimeoffset(7)
is_directory
bit
is_offline
bit
is_hidden
bit
is_readonly
bit
is_archive
bit
is_system
bit
is_temporary
bit

Each FileTable includes also these computed (read-only) columns:
Column Name
Data Type
parent_path_locator
hierarchyid
file_type
nvarchar(255)
cached_file_size
bigint


You can query, update, insert or delete this table the same way as a “normal” table from you database with T-SQL. You also can use a fulltextindex and so on.
So in the context of SharePoint, especially with BCS you are now able to integrate file system data in you SharePoint without writing code and without growing up you SharePoint contend database with BLOB data. You can use file system data like documents, multimedia files or whatever as a SharePoint  External List, integrate it in you Search environment and using SharePoint Features like tagging, export to SharePoint Workspace and so on.

SQL 2012 File Tabel with SharePoint - for me a fantastic combination

Montag, 5. Dezember 2011

Donnerstag, 1. Dezember 2011

COUNT and SIZE of all docs in your SP2010 contend DB

There are a lot of use cases and scenarios you have to know the size and the count of the docs in you SharePoint content db. You can find it out in different ways, using the PowerShell , the Search (with a query like "%% -aspx -bdc3 -file") or 3th party tools. Another ways, and of cause a really smart one, is querying directly the SP contend db. The query if fired with a NOLOCK hint, so the load impact on your SharePoint system is really low.
The following scripts are written for SharePoint 2010:
--"count" and "size" of all docs in your SP2010 contend DB
--run script against your SharePoint 2010 wss_Content..... db
SELECT
COUNT(*) AS 'Count',
(SUM(CONVERT(bigint,Size))/1024) AS 'Size in kbyte',
((SUM(Size)/1024)/COUNT(*)) AS 'AVG Size per Doc. in kbyte'
from dbo.AllDocs WITH(NOLOCK)
WHERE ID IN
(
SELECT tp_DocID FROM dbo.AllUserData WITH(NOLOCK)--comment this clause out if you also want include the SP systemfiles
)
AND Size is NOT NULL
AND Extension != '000'

--"count" and "size" of all docs in your SP2010 contend DB group by fileextension
--run script against your SharePoint 2010 wss_Content..... db
SELECT
COUNT(ID) AS 'Count',
(SUM(CONVERT(bigint,Size))/1024) AS 'Size in kbyte', --covert because of an "int" overflowrisk in a lager db
Extension AS 'Filetype',
((SUM(Size)/1024)/COUNT(*)) AS 'AVG Size per Doc. in kbyte'
from dbo.AllDocs WITH(NOLOCK)
WHERE ID IN
(
SELECT tp_DocID FROM dbo.AllUserData WITH(NOLOCK) --comment this clause out if you also want include the SP systemfiles
)
AND Size is NOT NULL
AND Extension != '000'
GROUP BY
Extension
ORDER BY 'Size in kbyte' DESC