This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT spid, kpid, blocked, d.name as dbname, open_tran, status, hostname, cmd, login_time, loginame, net_library | |
FROM sys.sysprocesses p | |
LEFT JOIN sys.databases d ON p.dbid=d.database_id | |
ORDER BY d.name, loginame |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT d.name AS "Database" | |
, ISNULL(CONVERT(VARCHAR, b.backupdate, 120), 'NEVER') AS "Last Full Backup" | |
FROM sys.databases d | |
LEFT JOIN ( | |
SELECT database_name, type, MAX(backup_finish_date) AS backupdate | |
FROM msdb.dbo.backupset | |
WHERE type LIKE 'D' | |
GROUP BY database_name, type | |
) b on d.name=b.database_name | |
WHERE (backupdate IS NULL OR backupdate < getdate()-1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare @Time_Start datetime = getdate()-7; | |
declare @Time_End datetime = getdate(); | |
-- Create the temporary table | |
DECLARE @ErrorLog TABLE (logdate datetime | |
, processinfo varchar(255) | |
, Message varchar(500)) | |
-- Populate the temporary table | |
INSERT @ErrorLog (logdate, processinfo, Message) | |
EXEC master.dbo.xp_readerrorlog 0, 1, null, null , @Time_Start, @Time_End, N'desc'; | |
-- Filter the temporary table |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT total_physical_memory_kb/1024 as "Physical Memory MB" | |
, available_physical_memory_kb/1024 as "Available Memory MB" | |
, available_physical_memory_kb/(total_physical_memory_kb*1.0)*100 AS "% Memory Free" | |
FROM sys.dm_os_sys_memory |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALTER USER <user name> WITH PASSWORD = '<new password>' OLD_PASSWORD = '<old password>' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create login <user name> with password = '<password>', default_database = <db name>; | |
create user <user name> from login <user name> with default_schema = dbo; | |
alter role <role> add member <user name>; | |
grant showplan to <user name>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alter session force parallel dml parallel 16; | |
alter session force parallel query parallel 16; | |
SET SERVEROUTPUT ON SIZE 1000000 | |
DECLARE | |
PROCEDURE migrateTable(sourceTable varchar2) IS | |
interimTable varchar2(30) := 'XX' || substr(sourceTable, '3'); | |
str varchar2(1000); |
NewerOlder