SQL Server

Find tables with column that contains certain text:

1
2
3
4
5
6
SELECT c.name AS ColumnName, t.name AS TableName
FROM sys.columns AS c
JOIN sys.tables AS t
    ON c.object_id = t.object_id
WHERE c.name LIKE '%YOUR COLUMN NAME%'
ORDER BY ColumnName

Find all duplicated records in table ids:

1
2
3
4
5
SELECT DISTINCT p.*
FROM ids p
JOIN ids q
    ON p.VALUE = q.VALUE
        AND p.KEY <> q.KEY

Select top 10 records of each group:

1
2
3
4
5
6
7
8
SELECT rs.Field1,rs.Field2 
FROM (
    SELECT *, ROW_NUMBER() OVER (
        PARTITION BY Section
        ORDER BY RankCriteria DESC
    ) AS RowNo
    FROM table
) rs WHERE RowNo <= 10

SQL Server Analysis Services

Checklist for Memory Optimizations in PowerPivot and Tabular Models: