Archive for category Programmer

How to determine table data sizes via T-SQL

I needed a quick and dirty way to find out how much data tables were consuming in a SQL Server database. Ripping off what sp_spaceused does, I came up with this:

SELECT
    t.name,
    LTRIM (STR (
        SUM (
        CASE
        WHEN (index_id < 2) THEN (in_row_data_page_count + lob_used_page_count + row_overflow_used_page_count)
        ELSE lob_used_page_count + row_overflow_used_page_count
        END
    )  * 8, 15, 0) + ' KB') AS DataSize
FROM sys.dm_db_partition_stats s
INNER JOIN sys.tables t ON t.object_id = s.object_id
GROUP BY t.name

Tags: , ,

Inconsistent line ending style upon Subversion Import / Commit

For posterity and my future sanity (and hopefully this helps the rest of us SVN-crazy developers).

When doing IMPORT or COMMIT operations using Subversion, we can receive a message like “Inconsistent line ending style”.

Particularly when IMPORTING, this can be a frustrating occurrence, with a host of hints provided online, but I couldn’t find anything but “brute force” approaches of converting EOL symbols by touching each file.

I use [auto-props] in my svn config file, and this is both part of the problem and the ultimate solution.

The latest occurrence happened when IMPORTING several XML files into a Repository. The confusing part is many of the XML files reported success, and then SVN hit an XML file with a different EOL style than all the others.

My auto-props entry used to be: [plain] *.xml = svn:mime-type=text/xml;svn:eol-style=native;svn:keywords=Date Revision[/plain]

Here’s my solution (svn config file): [plain] [auto-props] *.xml = svn:mime-type=text/xml;svn:eol-style=CRLF;svn:keywords=Date Revision [/plain]

[plain] [miscellany] enable-auto-props = yes [/plain]

Hopefully this helps you out as well.

kick it on DotNetKicks.com

Tags: ,

Resharper Tip : To-do Explorer

Do you find your code riddled with

throw new NotImplementedException();

or

// TODO:

Did you know that Resharper provides support to find those elements quickly?

When using the Visual Studio keyboard mappings, you can bring up the To-do Explorer with [Ctrl+Alt+D] or click on the Resharper > Windows > To-do Explorer.

For futher tweaking, check out the “To-do Items” in the Resharper Options window. It provides full RegEx capability for creating your own patterns!



kick it on DotNetKicks.com

Tags: , ,