Archives: February 2012
Removing Identical Duplicate Rows
Deleting duplicate rows out of a table can be tricky. A brute force way to do this is with a TOP 1 and a cursor, but clearly there are set-based ways to accomplish this. Using the ROW_NUMBER function with an appropriate OVER is fast and simple to understand.
This is…
This is…
3 comments, 2,992 reads
Posted in SQL Tact on 21 February 2012
Find Dependencies
Here's a script from my toolbox I use to find dependencies between SQL objects. The where clause has a number of sample filters.
--dependencies by dependency
select
ReferencingObjectName = rs.name + '.' + ro.name
, ReferencingObjectType = ro.type_desc
, ReferencedObjectName = s.name…
--dependencies by dependency
select
ReferencingObjectName = rs.name + '.' + ro.name
, ReferencingObjectType = ro.type_desc
, ReferencedObjectName = s.name…
0 comments, 275 reads
Posted in SQL Tact on 21 February 2012
..This operation must be performed in the master database."
"Cannot alter a server audit from a user database. This operation must be performed in the master database."
If you're trying to enable or disable a Audit or Server Audit Spec in SSMS, even if you're a sysadmin, you'll get the above failure if your default database isn't master.
If…
If you're trying to enable or disable a Audit or Server Audit Spec in SSMS, even if you're a sysadmin, you'll get the above failure if your default database isn't master.
If…
0 comments, 300 reads
Posted in SQL Tact on 3 February 2012



Subscribe to this blog