Friday, June 14, 2013

SQL to get the tables and its row count

Below is the SQL we can use to get the tables and its row count.
CREATE TABLE #counts
(
    table_name varchar(255),
    row_count int
)

EXEC sp_MSForEachTable @command1='INSERT #counts (table_name, row_count) SELECT ''?'', COUNT(*) FROM ?'
SELECT table_name, row_count FROM #counts ORDER BY table_name, row_count DESC

drop table #counts



Alternatively, can use this SQL, it will give the same result:
DECLARE @sql nvarchar(MAX)

SELECT
    @sql = COALESCE(@sql + ' UNION ALL ', '') +
        'SELECT
            ''' + s.name + '.' + t.name + ''' AS ''Table'',
            COUNT(*) AS Count
            FROM ' + QUOTENAME(s.name) + '.' + QUOTENAME(t.name)
    FROM sys.schemas s
    INNER JOIN sys.tables t ON t.schema_id = s.schema_id
    ORDER BY
        s.name,
        t.name

EXEC(@sql)


Reference: here

Thursday, June 13, 2013

[System.Web.HttpException]: {"File does not exist."}

Did you encounter this error? Dunno where exactly the error is??
Same me too..

Resolution is check your css file.
There could be an image reference from the css file that is not valid anymore.
That's the case for me.
So after I remove the css that refer to the invalid file path, it didn't give such error anymore.

Reference: here