Get Fairly Accurate Table Counts

Here’s a simple script that I use often – a quick hitter to find table row counts, that doesn’t use the Select Count(*). It uses the sysindexes table thus the reason it’s called “fairly accurate”.

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 [...]

Script to display all date formats

I’m writing this in response to Adam Machanic’s – T-SQL Tuesday - #001: Date/Time Tricks.

Here’s the a very useful script I still use all the time.  I created it when I was working on a reporting project – it simply displays all the different date formats in SQL server.

–If you are looking to display dates, [...]