Command prompt shortcut to open a Microsoft SQL Server database directly

You might have started looking for a shortcut if you have been using Microsoft SQL Server for a long time. Once you have many databases in Microsoft SQL Server Management Studio, it becomes quite cumbersome to navigate through lists to find the database you want to work with.

There is an easier way to connect your favorite database and start sending queries right away. Simply use the following command. It will open Microsoft SQL Server with your database automatically connected.

ssms.exe -S serverIP -d databaseName-E - U userName-P password

Check out the parameters below if you want to customize this query further:

ssms.exe [-S server_name[\instance_name]] [-d database] [-U user] [-P password] [-E] [-G] [-nosplash] [file_name[, file_name]*] [-log [file_name]?] [-?]

[-S The name of the SQL Server instance to connect to]
[-d The name of the SQL Server database to connect to]
[-E] Use Windows Authentication to login to SQL Server
[-U The name of the SQL Server login to connect with]
[-P The password associated with the login]
[-G] Use Azure Active Directory for authentication
[-nosplash] Suppress splash screen
[file_name[, file_name]*] Names of files to load
[-log [file_name]?] Logs SQL Server Management Studio activity to the specified file for troubleshooting
[-?] Displays this usage information

 

Solved: “Could not load file or assembly ‘Microsoft.SqlServer.Management.Sdk. The system cannot find the file specified”

You may run into the error below while doing development in Visual Studio:

Could not load file or assembly ‘Microsoft.SqlServer.Management.Sdk.Sfc, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91′ or one of its dependencies. The system cannot find the file specified.

Solution

You are missing SQL Server libraries that connects Visual Studio to SQL Server database. In order to fix this issue, download and install these two packages from the following URL.

  • SharedManagementObjects.msi
  • DB2OLEDBV5_x64.msi

Download: www.microsoft.com/en-us/download/details.aspx?id=35580

Note: The URL above is for SQL Server 2012. Download libraries for the version you use if it is not 2012 version.

SQL Server database size estimator

A pretty cool tool by Matthew Randle to get an estimation for your SQL Server database size. It’s very useful especially if you’re designing server/storage infrastructure in a new project.

Note: Since most data types and indexes have similar sizes in SQL Server and Oracle, you may want to use this tool for Oracle as well.

How it works

  1. Create a dummy database with main tables and indexes
  2. Put some sample data
  3. Run the tool. Connect to database
  4. It will create a spreadsheet with the current size

Play with row counts so you can estimate the size it’ll have in the future

Download

More