Sunday, February 7, 2016

List of procedures executed now / when executed



List of procedures executed now, WITH DB Name

SELECT TOP 10 d.object_id, d.database_id, OBJECT_NAME(object_id, database_id) 'proc name',
    d.cached_time, d.last_execution_time, d.total_elapsed_time,
    d.total_elapsed_time/d.execution_count AS [avg_elapsed_time],
    d.last_elapsed_time, d.execution_count ,DB_NAME(d.database_id)
FROM sys.dm_exec_procedure_stats AS d

ORDER BY [d].last_execution_time DESC;

Wednesday, February 3, 2016

ENCRYPT / DECRYPT SQL SERVER



DECLARE @x VARBINARY(8000) = ENCRYPTBYPASSPHRASE('MKSABC','2424');
-- SELECT AFTER DECRUPT
SELECT @x , CONVERT(VARCHAR(32), DECRYPTBYPASSPHRASE('MKSABC', @x)) 'AFTER DECRUPT';