Skip to content

Instantly share code, notes, and snippets.

@lionofdezert
lionofdezert / DatabaseRestoreLog.sql
Created August 2, 2012 11:47
Database Restore Log
/************************
Script Purpose: To Keep Database Restore Log
Script By : Aasim Abdullah for https://connectsql.blogspot.com
************************/
USE master
GO
CREATE TABLE DatabaseRestoreLog
(DatabaseName VARCHAR(50), RestoreDate DATETIME, RestoredFrom VARCHAR(500))
@lionofdezert
lionofdezert / TablesRelationshipTSQL.sql
Created July 31, 2012 16:27
SQL Server : Tables Relationship Report Through TSQL
-- Tables Relationship Script
-- Script By: Syed Muhammad Yasir for http://connectsql.blogspot.com
-- Updated August 1, 2012
--
SELECT CASE WHEN a.parent_object_id IS NULL
THEN parent.name + '-1--*-' + child.name
ELSE parent.name + '-1--1-' + child.name
END AS TablesWithRelations
@lionofdezert
lionofdezert / DatabaseGrowthHTMLReport.sql
Created July 24, 2012 08:02
SQL Server: Script to Generate HTML Report/mail for Databses Current Size, Growth Rate and Available Disk Space
/*
Script to send an alert through mail, with information that how many drive
space is required from next databases growth on a specific instance and how many
space is available.
Script By: Amna Asif for ConnectSQL.blogspot.com
*/
@lionofdezert
lionofdezert / LogonTrigger.sql
Created July 24, 2012 07:21
SQL Server: Restrict Login from Valid Machine IPs Only (Using Logon Trigger)
USE master
GO
-- Create table to hold valid IP values
CREATE TABLE ValidIPAddress (IP NVARCHAR(15)
CONSTRAINT PK_ValidAddress PRIMARY KEY)
-- Declare local machine as valid one
INSERT INTO ValidIPAddress
SELECT '<local machine>'