SQLCMD to export sql data

export to a csv

sqlcmd -S . -d DatabaseName -E -s',' -W -Q "SELECT * FROM TableName" > C:\Test.csv

SQL script to view sizes of all tables

SELECT
    t.NAME AS TableName,
    p.rows AS RowCounts,
    SUM(a.total_pages) * 8 AS TotalSpaceKB, 
    SUM(a.used_pages) * 8 AS UsedSpaceKB, 
    (SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB
FROM
    sys.tables t
INNER JOIN     
    sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN
    sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
INNER JOIN
    sys.allocation_units a ON p.partition_id = a.container_id
WHERE
    t.NAME NOT LIKE 'dt%'
    AND t.is_ms_shipped = 0
    AND i.OBJECT_ID > 255 
GROUP BY
    t.Name, p.Rows
ORDER BY
    t.Name

A SQL server search plugin, from Redgate

It is free.

image

You can download it from this link http://www.red-gate.com/products/sql-development/sql-search/

After the installation, you can see the button in your Sql server management studio. “SQL Search”

image

 

image

Type the keywords and change the filters to find whatever objects contain your keywords. A great tool for a complex database which has more than 200 tables and stored procedures.