But I’m only running Select Queries!

Just because you only have db_datareader access to production doesn’t mean you can’t cause a great deal of harm. I’ve worked in a few areas where against my advice, we have developers, analysts and report writers who  still have access to Production Environments. Normally most business owners have finally relented Continue Reading

List Foreign Keys, Parent and Referenced Columns

SELECT fk.name AS ForeignKey_Name, ob.name AS ParentTableName, col.name AS ParentColName, ob2.name AS ReferencedTableName, RCol.name AS ReferenceColName FROM sys.foreign_keys AS fk INNER JOIN sys.objects AS ob ON fk.parent_object_id = ob.object_id CROSS JOIN sys.objects AS ob2 INNER JOIN sys.foreign_key_columns AS fkc ON fk.object_id = fkc.constraint_object_id INNER JOIN sys.COLUMNS AS COL ON col.object_id Continue Reading