Categories
PowerShell

Pipe output to clipboard

You can use the command line program clip to pipe the output of a command to your clipboard.

Write-Output "Hello World!" | clip
Categories
SQL Server Visual Studio

Share a LocalDB instance with other users on the computer

MS LocalDB has the possibility to share your personal LocalDB instance with other users on the computer.

You can use the CLI tool SqlLocalDb.exe to share the instance. It is available in the Developer Command Prompt of Visual Studio.

This is the documentation of the share action:

share|h ["owner SID or account"] "private name" "shared name"
    Shares the specified private instance using the specified shared name.
    If the user SID or account name is omitted, it defaults to current user.

Usage:

C:\Windows\System32>sqllocaldb share contosolab\doering MSSQLLocalDB ShareLocalDb
Private LocalDB instance "MSSQLLocalDB" (owner: CONTOSOLAB\doering) shared with the shared name: "ShareLocalDb".

Important: the argument “owner SID or account” must be your own user not the user you want to share the instance with.

The instance then appears as .\ShareLocalDb in the list.

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional>sqllocaldb info
.\ShareLocalDb
MSSQLLocalDB

You can use the shared instance in connection strings like this:

Data Source=(LocalDb)\.\ShareLocalDb;database=MyDatabase;trusted_connection=yes;