Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

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…

Read more

3 comments, 3,319 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…

Read more

0 comments, 487 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…

Read more

0 comments, 487 reads

Posted in SQL Tact on 3 February 2012