Updating LocalDB

TLDR

The ‘Basic’ option in the SQL Express installer doesn’t install LocalDB, you need to switch to ‘Download Media’ and select it as the option there.

Backstory

I recently discovered that although Visual Studio installs a version of LocalDB it is not necessarily the latest one (or updated when Visual Studio updates) and I ran in to problems while trying to run a script containing OPTIMIZE_FOR_SEQUENTIAL_KEY which requires v15 - two versions above the version installed by Visual Studio.

To upgrade LocalDB I followed this article including running:

C:\                         
λ sqllocaldb stop MSSQLLocalDB          
LocalDB instance "MSSQLLocalDB" stopped.
                                        
C:\                    
λ sqllocaldb delete MSSQLLocalDB        
LocalDB instance "MSSQLLocalDB" deleted.
                                        
C:\                        
λ sqllocaldb create MSSQLLocalDB        
LocalDB instance "MSSQLLocalDB" created with version 15.0.2000.5.
                                        
C:\                          
λ sqllocaldb start MSSQLLocalDB         
LocalDB instance "MSSQLLocalDB" started.

And then manually attaching the databases via SSMS. The only minor issue was that I wasted time assuming the ‘Basic’ install option would deal with LocalDB - and it did not. For future reference, if you only want the LocalDB part then select ‘Download Media’ and select it through there.

Written on March 9, 2021