Wednesday, October 2, 2013

Check the enforced password expiration setting of all users on SQL Server


select name,is_expiration_checked
from sys.sql_logins
where is_expiration_checked=1

Monday, September 16, 2013

SQL Server Trace Files (Database Schema Chang History)

EXEC master.dbo.sp_configure 'allow updates', 1;
GO
EXEC master.dbo.sp_configure 'show advanced options', 1;
GO
EXEC master.dbo.sp_configure 'default trace enabled', 1;
GO
RECONFIGURE WITH OVERRIDE;
GO

SELECT * FROM sys.configurations WHERE configuration_id = 1568

SELECT * FROM ::fn_trace_getinfo(0)

SELECT   * FROM sys.traces
WHERE id = 1;

Wednesday, June 26, 2013

How to Find the Original Install Date and Time of Windows OS

 cmd /k systeminfo | find "Original Install Date" 

Wednesday, June 19, 2013

Checking SET Options for the Current Session in SQL Server

DECLARE @options INT

SELECT @options = @@OPTIONS

PRINT @options
IF ( (1 & @options) = 1 ) PRINT 'DISABLE_DEF_CNST_CHK'
IF ( (2 & @options) = 2 ) PRINT 'IMPLICIT_TRANSACTIONS'
IF ( (4 & @options) = 4 ) PRINT 'CURSOR_CLOSE_ON_COMMIT'
IF ( (8 & @options) = 8 ) PRINT 'ANSI_WARNINGS'
IF ( (16 & @options) = 16 ) PRINT 'ANSI_PADDING'
IF ( (32 & @options) = 32 ) PRINT 'ANSI_NULLS'
IF ( (64 & @options) = 64 ) PRINT 'ARITHABORT'
IF ( (128 & @options) = 128 ) PRINT 'ARITHIGNORE'
IF ( (256 & @options) = 256 ) PRINT 'QUOTED_IDENTIFIER'
IF ( (512 & @options) = 512 ) PRINT 'NOCOUNT'
IF ( (1024 & @options) = 1024 ) PRINT 'ANSI_NULL_DFLT_ON'
IF ( (2048 & @options) = 2048 ) PRINT 'ANSI_NULL_DFLT_OFF'
IF ( (4096 & @options) = 4096 ) PRINT 'CONCAT_NULL_YIELDS_NULL'
IF ( (8192 & @options) = 8192 ) PRINT 'NUMERIC_ROUNDABORT'
IF ( (16384 & @options) = 16384 ) PRINT 'XACT_ABORT'

http://www.mssqltips.com/sqlservertip/1415/determining-set-options-for-a-current-session-in-sql-server/

Monday, June 17, 2013

Plan cache and optimizing for adhoc workloads (fixing plan cache bloat problem)

SELECT objtype AS [CacheType]
        , count_big(*) AS [Total Plans]
        , sum(cast(size_in_bytes as decimal(18,2)))/1024/1024 AS [Total MBs]
        , avg(usecounts) AS [Avg Use Count]
        , sum(cast((CASE WHEN usecounts = 1 THEN size_in_bytes ELSE 0 END) as decimal(18,2)))/1024/1024 AS [Total MBs - USE Count 1]
        , sum(CASE WHEN usecounts = 1 THEN 1 ELSE 0 END) AS [Total Plans - USE Count 1]
FROM sys.dm_exec_cached_plans
GROUP BY objtype
ORDER BY [Total MBs - USE Count 1] DESC
go

Turn "Optimize for Ad Hoc Workloads" on

http://www.sqlskills.com/blogs/kimberly/plan-cache-and-optimizing-for-adhoc-workloads/

Thursday, May 23, 2013

enables the SQL Server Agent extended stored procedures in SQL Server 2012


The possible values are:

0, indicating that SQL Server Agent extended stored procedures are not available (the default).

1, indicating that SQL Server Agent extended stored procedures are available.


The following example enables the SQL Server Agent extended stored procedures.

sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Agent XPs', 1;
GO
RECONFIGURE
GO

Thursday, April 4, 2013

Installing Web Front End Only requires install from command line


If you want to install just a web front end, you have to run the install from the command line. 

Follow the instructions at http://technet.microsoft.com/en-us/library/cc262897.aspx and create a config file for server type="WFE"