SQL Server 2022 LocalDB Download

TLDR: here is the URL to download the English (en-US) MSI installer for SQL Server 2022 LocalDb:

For (my) future reference: here’s how I found it

  • Download the SQL Server 2022 Express Installer SQL2022-SSEI-Expr.exe from the the SQL Server downloads page.
  • Open it in ILSpy.
  • Save the Microsoft.Sql.Installer.UI.Externals.InstallerEngine.dll embedded resource to a new file.
  • Open this file in ILSpy also and locate the Manifest_Media_Express_en-US.xml embedded resource, in which you will find a reference to SqlLocalDB.msi, which combined with the DownloadRoot URL just above it gives you the required location.

If you want the installer for other languages (e.g. German (de-DE), Spanish (es-ES)) then look in the Manifest_Media_Express XML file for that language.

SQL Server database space usage

Ever wanted to know what the biggest table in your database is, and what the other space hogs are? There is the sp_spaceused system stored procedure that either shows headline stats for the database as a whole, or those for a particular table. Annoyingly it doesn’t tell you which table is taking up all the space relative to all the others. If you have SQL Server SP2 installed then it ups SQL Management Studio

So, here’s a T-SQL batch that shows all the space taken up by tables in the current database. The main column to look at is “Total size”, which is a sum of the Data size, Index size and Unused columns.

CREATE TABLE #spaceused
    Name nvarchar(255),
    Rows int,
    [Total size] varchar(50),
    [Data size] varchar(50),
    [Index size] varchar(50),
    Unused varchar(50)
DECLARE @table_name nvarchar(255) 

    SELECT name FROM sysobjects WHERE type='U'
OPEN tables_cursor
FETCH NEXT FROM tables_cursor INTO @table_name
    INSERT INTO #spaceused EXEC sp_spaceused @table_name
    FETCH NEXT FROM tables_cursor INTO @table_name

SELECT * FROM #spaceused
    ORDER BY CONVERT(int, LEFT([Total size],
                     CHARINDEX(' KB', [Total size]))) DESC 

DROP TABLE #spaceused
CLOSE tables_cursor
DEALLOCATE tables_cursor

Of note is the very useful INSERT INTO table EXEC proc technique for capturing the output of a stored proc.

The script works on SQL Server 2000 and 2005 (and possibly later).