Here are some security tasks I've been tackling lately.
1. Find weak passwords and change them.
I keep track of application logins and passwords using a product called
KeePass. It has a plugin called
strengthreport that you can use to make a report or .csv showing the strength of your passwords. Use the SVN command …
Continue Reading ›› I was looking for a code example of this on the web, but couldn't find it, so here it is. You would need to create the @cmd of course with your own variables.
SELECT @cmd = 'restore filelistonly from disk = ''' + @localBackupPath
… Continue Reading ››
Here is a bit of code, adapted from
Nigel Rivett's original. You can use this to copy one database over another or restore the most recent database over itself.
--BEGIN TRAN
IF EXISTS ( SELECT *
FROM … Continue Reading ››
WARNING: Use caution in running scripts you find on the internet. You are responsible for the well being of your systems!
We're sitting around waiting for the SAN monkeys to fling some crap our way - not the SAN guys, the SAN monkeys, kinda like gremlins, but not as bad. Our …
Continue Reading ›› This cursor inserts all of the roles and members from each database into your admin database.
USE [SQL_DBA_Sandbox]
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Roles]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Roles](
[DBName] [varchar](max) NULL,
[Role] [varchar](max) NULL,
[Member] [varchar](max) NULL
) ON [PRIMARY]
END
ELSE
Continue Reading ››
Oh no! A useful cursor?
DECLARE @DB_NAME sysname;
SET @DB_NAME = NULL;
CREATE TABLE #RESULTS
(TABLE_CATALOG sysname,
TABLE_SCHEMA sysname)
DECLARE @SQL VARCHAR(2000);
DECLARE Cursor_DB CURSOR FAST_FORWARD READ_ONLY FOR
SELECT name FROM sys.databases
WHERE database_id > 4
OPEN Cursor_DB
FETCH NEXT FROM Cursor_DB INTO @DB_NAME
WHILE … Continue Reading ››