Skip to content

Instantly share code, notes, and snippets.

@brentmaxwell
brentmaxwell / rowcounts.sql
Created March 17, 2015 19:21
Get *approximate* row counts of all tables in a db
SELECT
[TableName] = so.name,
[RowCount] = MAX(si.ROWS)
FROM
sysobjects so,
sysindexes si
WHERE
so.xtype = 'U' AND
si.id = OBJECT_ID(so.name)
GROUP BY so.name ORDER BY so.name
@brentmaxwell
brentmaxwell / UnixTimeExtensions.cs
Created March 17, 2015 19:18
Extensions to convert Unix time to DateTime
namespace System
{
public static class UnixTimeExtensions
{
public static long ToUnixTime(this DateTime datetime)
{
return (long)(datetime.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds;
}
public static DateTime FromUnixTime(long time)