SELECT CL.* FROM INFORMATION_SCHEMA.TABLES CL WHERE TABLE_NAME LIKE '%BAND%'
2. Enumerate all columns in all tables with column name like MYCOLNAME
SELECT CL.* FROM INFORMATION_SCHEMA.COLUMNS CL WHERE column_name
LIKE '%MYCOLNAME%' ORDER BY table_name
3. Enumerate all columns in all tables with column name like MYCOLNAME, show table name as well
SELECT CL.TABLE_NAME, CL.COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS CL
INNER JOIN INFORMATION_SCHEMA.TABLES TB
ON TB.TABLE_NAME = CL.TABLE_NAME
WHERE CL.COLUMN_NAME LIKE '%MYCOLNAME%'
AND TB.TABLE_TYPE = 'BASE TABLE'
ORDER BY CL.TABLE_NAME
4. Find duplicate rows in a table in SQL Server
SELECT COL1, COL2, COUNT(*)
FROM T1
GROUP BY COL1, COL2
HAVING COUNT(*) > 1
5. Enumerate processes
USE master
SELECT * FROM sysprocesses
No comments:
Post a Comment