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

free trials by mail
free cialis
free cialis offer
cialis free trial
free cialis pills

free trials by mail
free cialis
free cialis offer
cialis free trial
free cialis pills

cialis 5mg cost
free cialis sample
free coupon for cialis
cialis free samples
cialis 30 day trial

cheap viagra free shipping order cialis cheap viagra from canada

Hi there! norco online pharmacy very good site http://onlinegenepharmacy.com

Hi there! norco online pharmacy very good site http://onlinegenepharmacy.com

Hi there! norco online pharmacy very good site http://onlinegenepharmacy.com

Howdy! pharmacy tech certification online very good internet site http://onlinegenepharmacy.com

Howdy! pharmacy tech certification online very good internet site http://onlinegenepharmacy.com

Howdy! pharmacy tech certification online very good internet site http://onlinegenepharmacy.com

Howdy! pharmacy tech certification online very good internet site http://onlinegenepharmacy.com

Hello there! online pharmacy technician certification beneficial internet site http://onlinepharmacycanadaus.com

Hi there! online pharmacy technician great site http://onlinepharmacycanadaus.com

Hi there! online pharmacy technician great site http://onlinepharmacycanadaus.com

Hi! non prescription pharmacy beneficial internet site http://onlinepharmacycanadaus.com

Hi! non prescription pharmacy beneficial internet site http://onlinepharmacycanadaus.com

Hello there! pharmacy technician schools online beneficial website http://onlinepharmacycanadaus.com

Hello there! pharmacy technician schools online beneficial website http://onlinepharmacycanadaus.com

Hello! online mexican pharmacy great web page http://onlinepharmacycanadaus.com

Abuso De Kamagra Baclofene Nantes Buy Nosipren Prednisone 20mg Priligy Revenue

Hello! online mexican pharmacy great web page http://onlinepharmacycanadaus.com

Hello there! compare prescription drug prices very good site http://canadiantrustpharmacyhd.com

Hi there! cialis coupon for pharmacy very good website http://canadiantrustpharmacyhd.com

Hi there! cialis coupon for pharmacy very good website http://canadiantrustpharmacyhd.com

Howdy! canada pharmacies free shipping very good web site http://canadiantrustpharmacyhd.com

Howdy! canada pharmacies free shipping very good web site http://canadiantrustpharmacyhd.com

Howdy! canada pharmacies free shipping very good web site http://canadiantrustpharmacyhd.com

Hi! canadian pharmacies generic viagra great web site http://canadiantrustpharmacyhd.com

Hi! canadian pharmacies generic viagra great web site http://canadiantrustpharmacyhd.com

Hi! canadian pharmacies generic viagra great web site http://canadiantrustpharmacyhd.com

Hi! canadian pharmacies generic viagra great web site http://canadiantrustpharmacyhd.com

Hello there! buy tadalafil buy finasteride association cialis et viagra great web site

Howdy! purchase tadalafil purchase finasteride cialis mail very good website

Howdy! purchase tadalafil purchase finasteride cialis mail very good website

Hello there! cialis buy propecia online without prescription viagra and cialis online excellent site

Hello there! cialis buy propecia online without prescription viagra and cialis online excellent site

Hello there! cialis buy propecia online without prescription viagra and cialis online excellent site

Hello there! cialis buy propecia online without prescription viagra and cialis online excellent site

Hello there! order cialis finasteride cialis tablets india tablets 20 mg excellent web page

Hello! [url=http://cialissmx.com/]buy cialis usa[/url] [url=http://propeciausfinasteridhq.com/]buy finasteride[/url] [url=http://cialissmx.com/]cialis profesional india[/url] excellent web page

Hello! [url=http://cialissmx.com/]buy cialis usa[/url] [url=http://propeciausfinasteridhq.com/]buy finasteride[/url] [url=http://cialissmx.com/]cialis profesional india[/url] excellent web page

Hello! where buy cialis order finasteride double dose of cialis good site

Hello! where buy cialis order finasteride double dose of cialis good site

Hi! purchase tadalafil buy propecia usa how can i buy cialis in a store in ct beneficial site

Pages