Articles

If you have large tables which have a table you need to delete data in order to avoid excessive growth you can add a SQL Agent job that deletes data older than for example 1 year.

DELETE FROM tableName
WHERE rec_date <= DateAdd(d,-365,GETDate())

This will delete data older than one year. If you run it daily then it might not be a big problem. If you have millions of rows to delete then you might use this script to delete 5000 rows at the time. You can increase the number of rows to delete but you have to consider it can prevent writing from your application. 

Set rowcount 5000
DELETE FROM tableName
WHERE rec_date <= DateAdd(d,-365,GETDate())

 

Source: https://stackoverflow.com/questions/4849652/find-all-tables-containing-column-with-specified-name

Search Tables 1:

SELECT      c.name  AS 'ColumnName'
            ,t.name AS 'TableName'
FROM        sys.columns c
JOIN        sys.tables  t   ON c.object_id = t.object_id
WHERE       c.name LIKE '%MyName%'
ORDER BY    TableName
            ,ColumnName;

Have you ever had the need to export all tables in a database to csv files? Run this command on your database: