Monthly Archives: February 2016

PowerShell – Backup Individual database and delete all it’s respective files by keeping a recent file

Problem Statement The requirement is to backup individual database and after successful backup the script should retain the most recent file and delete the rest from a directory for that specific database. The below Powershell script is used to backup a … Continue reading

Posted in PowerShell, SQL | Tagged , , | 4 Comments

SQL – List Server and DB Permsission

Database Level Permission DECLARE @DBuser_sql VARCHAR(4000) DECLARE @DBuser_table TABLE ( DBName VARCHAR(200), UserName VARCHAR(250), LoginType VARCHAR(500), AssociatedDatabaseRole VARCHAR(200) ) SET @DBuser_sql=’ SELECT “[?]” AS DBName,a.name AS Name, a.type_desc AS LoginType, USER_NAME(b.role_principal_id) AS AssociatedDatabaseRole FROM [?].sys.database_principals a LEFT OUTER JOIN [?].sys.database_role_members … Continue reading

Aside | Posted on by | Tagged , , , | 1 Comment