Recent Posts

  • TSQL Tuesday #93 -Do Not Drive During Interview

    TSQL Tuesday #93 -Do Not Drive During Interview

    I thank Kendra Little (b|t) for hosting TSQL Tuesday #93. Topic for this month Interviewing Patterns & Anti-Patterns. What advice do you have for people preparing for or going through an interview?.

    TSQL2SDAY-300x300

    After initial phone screening I went for in person interview. I was scheduled to meet 5 interviewer. Last person in the list was the manager to whom I will report if I work there. Things went very well with the first 4 interviewer. I was looking forward to meet the manager. I was told the manager is not onsite and they will connect …


  • Extended Event duration Millisecond or Microsecond?

    Extended Event duration Millisecond or Microsecond?

    There was a question in dba.stackexchange.com titled “module_end extended events duration in microseconds?” that I answered and it was Microsecond in that instance.
    Later on I questioned myself if the duration is always in Microseconds for extended events. I found, it is a mix of Millisecond, Microsecond and some are unknown meaning famous NULL. I wrote below tsql code to determine which is what.

    SELECT p.name package_name,
           o.name event_name,
           c.name event_field,
           DurationUnit= CASE
                             WHEN c.description LIKE '%milli%' 
                             THEN SUBSTRING(c.description, CHARINDEX('milli', c.description),12)
                             WHEN c.description LIKE '%micro%' 
                             THEN SUBSTRING(c.description, CHARINDEX('micro', c.description),12)
                             ELSE NULL
                         END,
           c.type_name field_type,
           c.column_type column_type
    FROM sys.dm_xe_objects o
    JOIN 

  • NULL Values in Histogram

    During my cardinality estimator presentation in DBA virtual group there was a question asked about NULL values and histogram. I am quoting the question as is “SQL Server include null values in the index. How are statistics handle for null values?”

    I will answer the question in this blog post.

    For demo purpose I will be using WideWorldImporters database which you can download and restore from here. In table [Sales].[Orders] column ‘PickingCompletedWhen’ does allow NULL values.

    How many rows are NULL and how many are NOT NULL?

    USE [WideWorldImporters];
    GO
    SELECT 'NULL' AS [Value], COUNT(*) AS [NumOfRecord]
    FROM [Sales].[Orders]