I am looking for ways to access LocalDb database between users using the share command of sqllocaldb command utility but I cannot see the database created in one user in another.
Here are my steps:
Login to user User1 on Windows 7
Create a new database called test using sqlcmd as follows
sqlcmd -S (localdb)\v11.0 create database test
Share the instance v11.0 as follows with User2
sqllocaldb share domain\User2 v11.0 myinstance
Switch to User 2
Login to shared instance as follows
sqlcmd -S (localdb)\.\myinstance
select name from sys.master_files
The above query does not display test database.
Why am I not able to see the databases in User 2 that was created in User1 after sharing?
I thought it must work based on blog (approach 2)http://blogs.msdn.com/b/sqlexpress/archive/2011/12/09/using-localdb-with-full-iis-part-2-instance-ownership.aspx#SharedLocalDB by Krzysztof Kozielczyk but it does not.
Any help/suggestion is appreciated.
Thanks Pare
Start the SQL Server, in the dialog window for the Server name enters the name of the instance that you want to connect with. From the Authentication drop down box, select the SQL Server Authentication and for the field Login and the Password enter your credentials then click the Connect button.
In the Command Prompt window, type the following command: SqlLocalDB create NewInstance and press the Enter key. The message will appear which indicates that the LocalDB instance is created: LocalDB instance “NewInstance” created with version 13.0. 2186.6.
Despite their differences, Microsoft still allows both to be used for production applications at no cost. LocalDB can act as an embedded database for a small application and SQL Server Express can act as a more robust, full-featured remote database engine for larger applications.
Once installed, LocalDB is an instance of SQL Server Express that can create and open SQL Server databases. The system database files for the database are stored in the local AppData path, which is normally hidden.
The reason this isn't working is because you're issuing the wrong command. The usage instructions from sqllocaldb.exe are:
share|h ["owner SID or account"] "private name" "shared name"
Based on this, your second command should be the SID or account that created the instance, not with the account you want to share the instance with. Sharing shares an instance with all accounts on the machine.
Assuming that your account created the instance you want to share, then the command you should issue is:
sqllocaldb share v11.0 myinstance
Otherwise, it should be:
sqllocaldb share "<account that created the instance>" v11.0 myinstance
In either case, you also need to ensure that you are running an elevated command window so it can be successfully shared.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With