SQL Server useful but less known features

  • Posted on: 2 November 2016
  • By: Michał Turecki
  1. Checking who is connected to the database

    sp_who

    SELECT
    NULL as [Connections by Database],
    [host_name] AS [Client Machine],
    db.name AS [Database],
    [program_name] AS [Client Program],
    COUNT(*) AS [Open Connections]
    FROM sys.dm_exec_sessions s (nolock)
    LEFT JOIN sys.dm_exec_requests r (nolock) ON r.session_id = s.session_id
    LEFT JOIN sys.databases db (nolock) ON db.database_id = r.database_id
    WHERE s.session_id >= 50 -- Ignore SQL Server processes
    GROUP BY [host_name], db.name, [program_name]
    ORDER BY [Client Machine], [Database], [Client Program]

  2. Adjusting connection pooling settings

    By default pool size is 100 per database with a command timeout (effectively a connection timeout) of 15 seconds. To increase add following to the connection string:

    Connection Timeout=30;Pooling='true';Max Pool Size=200

  3. Checking the size of column's contents

    To check how much data the column contains:

    SELECT *, DATALENGTH([column]) AS ColumnSizeInBytes FROM table

  4. Using SQL Server profiler

    Profiler is a powerful way to debug application performance problems, to check query execution time. If you're developing any application using SQL Server as a database, running it at least once for every application release can help with pinpointing possible performance issues. Remember the rule - there should be a constant number of queries regardless of the amount of records fetched - that way application will scale better. Sometimes it's better to replace a single complex query with more simpler queries because for each result row, columns shared by joins are repeated and delivered to client for processing many times.

Comments

Hello! buy valacyclovir pills buy propecia usa legitimate canadian mail order pharmacies beneficial web page

Howdy! buy valacyclovir buy finasteride no prescription overseas pharmacies that deliver to usa good website

Howdy! buy valacyclovir buy finasteride no prescription overseas pharmacies that deliver to usa good website

Hello! purchase valacyclovir finasteride approved canadian pharmacies online good website

Hello! buy valtrex buy finasteride pills canadian pharmacies top best beneficial site

Hello! buy valtrex buy finasteride pills canadian pharmacies top best beneficial site

Hello! buy valtrex buy finasteride pills canadian pharmacies top best beneficial site

Hello there! buy valtrex pills online buy propecia with no prescription pharmacy without dr prescriptions excellent site

Hello there! buy valtrex pills online buy propecia with no prescription pharmacy without dr prescriptions excellent site

Hello there! generic viagra online pharmacy canadian online pharmacy no prior prescription required pharmacy great internet site

Hello there! generic viagra online pharmacy canadian online pharmacy no prior prescription required pharmacy great internet site

Hello there! generic viagra online pharmacy canadian online pharmacy no prior prescription required pharmacy great internet site

Hi! pharmacies online mexico pharmacy online top rated canadian pharmacies online very good website

Hi! online pharmacy online pharmacy technician schools discount rx great internet site

Hi! online pharmacy online pharmacy technician schools discount rx great internet site

Hi! online pharmacy online pharmacy technician schools discount rx great internet site

Hello there! cvs pharmacy application online reputable canadian online pharmacy international pharmacies that ship to the usa beneficial internet site

Hello there! cvs pharmacy application online reputable canadian online pharmacy international pharmacies that ship to the usa beneficial internet site

Hello! no prescription online pharmacy canadian pharmacy medicine mexico very good site

Hello! no prescription online pharmacy canadian pharmacy medicine mexico very good site

Hello! no prescription online pharmacy canadian pharmacy medicine mexico very good site

Hello! no prescription online pharmacy canadian pharmacy medicine mexico very good site

Hello! cgv online pharmacy canadian pharmacy viagra online online canadian pharmacies very good site

Hello! cgv online pharmacy canadian pharmacy viagra online online canadian pharmacies very good site

Howdy! online pharmacies in india no prescription online pharmacy canadian drugstore reviews good internet site

Howdy! online pharmacies in india no prescription online pharmacy canadian drugstore reviews good internet site

Howdy! online pharmacies in india no prescription online pharmacy canadian drugstore reviews good internet site

Hello! health pharmacy online cvs pharmacy online refill no prescription pharmacy beneficial web site

Hello! health pharmacy online cvs pharmacy online refill no prescription pharmacy beneficial web site

Hello! health pharmacy online cvs pharmacy online refill no prescription pharmacy beneficial web site

Howdy! testosterone online pharmacy cheap pharmacy online pharmacy online excellent internet site

Howdy! testosterone online pharmacy cheap pharmacy online pharmacy online excellent internet site

Howdy! testosterone online pharmacy cheap pharmacy online pharmacy online excellent internet site

Howdy! testosterone online pharmacy cheap pharmacy online pharmacy online excellent internet site

Hello there! online pharmacy no prescription walgreen online pharmacy pharmacy without dr prescriptions great web page

Hello there! online pharmacy no prescription walgreen online pharmacy pharmacy without dr prescriptions great web page

Hello there! online pharmacy no prescription walgreen online pharmacy pharmacy without dr prescriptions great web page

Hello! buy cialis uk good web site.

Hello! buy cialis uk good web site.

Hello! buy cialis uk good web site.

Hello! buy cialis uk good web site.

Hi there! buy tadalafil pills excellent internet site.

Hello there! buy tadalafil pills beneficial web page.

Howdy! cialis cheap excellent internet site.

Howdy! cialis cheap excellent internet site.

Pages