Connect to localdb with sql-cli - sql-server

There is the sql-cli utlity (installed with npm) which I am using to connect to various SQL Server machines. It works perfectly, however when connecting to localdb it responds with an error. So the next command line works:
mssql -s SomeServerAddress
But this one doesnt work:
mssql -s (localdb)\v11.0
And it responds with
\v11.0 was unexpected at this time.
Is there any special formatting for the server name to work?
Thanks.

its because (localdb)\v11.0 is not an actual instance as it can only be used inside visual studio.
"The localdb is at the heart of SSDT; it’s similar to SQL Server Express under the hood and runs a full version of sqlserver.exe. However this is throttled by the numbers of CPUs and limits on resources. There are quite a lot of limitations; you cannot upgrade the instance and there is no management and the sqlserver.exe does not run as a service. It is not similar to SQL Server Compact as this is feature-less (no stored procedures or functions) it is actually a DLL file that runs in a process from within Visual Studio, but is not available to task manager or windows. It is awakened when the SQL Server Native Client requests a connection from within Visual Studio. It doesn't stay online forever, it shuts down after time. You can configure where it creates the SQL files required to run. The localdb does not support table partitioning or data compression at the moment. However there are not many features that it does not support. You can however configure SSDT to use a full version of SQL Server i.e. the Developer edition, if your project requires unsupported features; by changing the Debug Connections tring in the projects properies." - Andrew J Fenna

This works:
mssql-cli -E -S (localdb)\mssqllocaldb
The -E is for integrated auth, the -S is the server.
If it does not connect, try to start localdb:
sqllocaldb start mssqllocaldb
This is all that is needed. No need to start Visual Studio or any other tool.

You may alreaady have gone on to bigger and better things, but
mssql -s "(localdb)\MSSQLLocalDB"
has worked for me.
Regards

Related

How do I switch between two SQL connections in Visual Studio Code?

Since yesterday I have connections to two different SQL Servers in Visual Studio Code (VSCode). One is a SQL Server (called "DS") and the other is to our development environment which is SQL Server Express (called "AS"). Now VSCode seems to have locked on DBDS08 and I don't know how to change it so I'll run my SQL queries against AS. I don't the servers are linked.
Does anyone know how I should do to change between these SQL connections in VSCode?
The VSCode version I'm using is 1.59.0.
The SQL packages installed is:
SQL Server (mssql), version 1.13.0
SQL Database Projects, version 0.14.1
Due to security reasons VSCode is run from an environment that is without internet connection.
#Larnu is correct. On the bottom right, select the server path. A few seconds later the command panel extends with actions to take. Select disconnect. You will see a confirmation in the same place, select yes. To connect to another server select the Text Disconnected on the bottom right and in the command are select the server you want to connect to.

Portable SQL LocalDB or Express

For the testing purpose I need to have SQL Server configured on each dev machine.
So once test suite or case is started SQL Server should be accessible locally.
I can not share the common server (this can not be changed)
Compact Edition doesn't fit requirements - we have cross-DB queries which are not supported
Better not to have any pre-requisites for the dev environment (e.g. install SQL Server Express) - it is not preferable
Is there any chance to have portable Express/LocalDB editions? To start it manually before the test and to stop after?
If you have a recent version of Visual Studio installed you will also have SQL Server LocalDB installed. And it is not a service, but a process that will start on demand from another process.
I had to do a job with similar requirements as yours, they wanted to install the application on several computers but they wanted to process the data locally, use of a remote SQL Server was not an option for them (the files that they wanted to process had some sensitive information).
The best option for me due to the requirements was to use LocalDB 2012 and add it as pre-requisite on the APP installer, is just a matter of a few clicks and boom you have LocalDB 2012 working on that machine (the LocalDB MSI installer it's ~70mb).
Of course i had create the database and stored procedures if the database was not creater yet on that machine, nothing that you cannot when you start the application, hope it helps.

Can't find Microsoft SQL Server even if it is installed?

Regarding the following images, I have obviously installed the Microsoft SQL Server, but I can't find the exe-file or anything named Microsoft SQL Server in the start menu.
Anyone who knows what to do to solve this, or do I need to install something more?
SQL Server runs as a service. You can start and stop it from windows services. SSMS is a gui tool for managing ddl (creating and altering tables and index's for example) and dml (writing queries to inquire, update or add data to databases).SSMS comes free with every edition of SQL server - perhaps you didn't tick a box when installing? You can also do this stuff the old fashioned way using sqlcmd from command line(DBAs love this for some reason) but for us mortals SSMS is much less of a struggle. As an aside there are other guis such as Toad (expensive) and Heidisql (free) amongst others which will do the job.
Looks like you have the engine. What you've got to do now is install SQL Server Management Studio: https://msdn.microsoft.com/hr-hr/library/mt238290.aspx
Looks like you have the various SQL Server components that are installed by Visual Studio (recent version) or SQL Server Data Tools (as used by VS).

Doing clean install of SQL Server Express

I installed VS 2008, VS 2012 and the community version 2013 along with the matching SQL Servers but never needed the SQL Servers and never checked if they were properly installed.
I recently picked up SQL Server Management Studio and tried to connect to a server.
Unfortunately, it does not detect any local server, even though I have about twenty different entries in programs & apps for SQL Server related stuff including SQL Server 2012 and 2014 Express Localdb, an installation of SQL Server 2008, data-tier app frameworks, native clients, transact SQL, a couple "compact" versions, tools and what's not.
One would think that something in this mess would be recognized as a server, but apparently not so. I had an entry for SQL Server in the start menu with a nice GUI with an install DB option... that requested a server media folder (lord knows which). I tried starting manually one of the many SQL Servers (sqlservr.exe) from the program files folders to no avail (I get a message about a corrupt installation)
My DB experience is pretty much exclusively with MySQL and I am lost with all these applications that look like they should do something but don't.
I would like to have a bare bones installation that works for the following use:
Coding Winform apps with local databases (compatible with Entity Framework)
Allows to distribute the apps with local databases for free (commercial use, small data volume)
Running SQL queries from SQL Server Management Studio
What is the minimum I need for this purpose?
Should I uninstall all the existing SQL Server related programs and make a clean install from a single install file (for instance, would installing the 1.1gb SQL Server 2014 Management Studio Express 64 Bit.exe give me all I need)?
Or if not, is there any way to install a recent version and ignore the underlying mess? (I don't really care for the disk space, I just want this thing to work).
I apologize if this question is a mess but I am pretty confused with this, and I could really use a hand figuring out what's what.

Can a WPF app with .sdf database run on a computer without SQL Server installed

This question may seems a bit silly. The thing is I'm programming a WPF using VS2010, which contains a .sdf database (connection is ADO.NET).
Someone told me that if I use a SQL Server Express database it can be run on any PC even it has no SQL Server installed. But after I tried executing in my virtual machine (win7 & win xp), seems it cannot even start up.
So, can someone brief me, what database do people normally use in developing WPF software? Is it true that my program using a SQL Server database file cannot execute on PC without SQL Server installed?
Much appreciate in advance!
Yes, it can!
SQL Server Compact (that produces and uses .sdf) is the only SQL Server edition that does not require a server to be installed. All its code and logic is contained in the handful of DLL's that you need to include with your application. Just ship your app with those DLL's and you should be fine.
Read more about SQL Server Compact and how to use and deploy it on MSDN.
SQL Server Express (and any of the other editions, like Web, Standard, Developer, Enterprise) on the other hand does require an installation of the SQL Server Express edition - either on that machine, or somewhere in the network where your app runs (remote connections from the network are disabled by default, but can be enabled).

Resources