LocalDb V11.0 on Docker - sql-server

I am using Visual Studio 2017 for my project but unfortunately there is no support for LocalDb V11. So I would like to have a Docker container with it but couldn't find any existing image for it.
I'd like to have the following connection string to my DB:
"Data Source=(LocalDB)\\v11.0;Initial Catalog={0};Integrated Security=True; Trusted_connection=true;Connection Timeout=60"
So my question is there any Docker Sql-server image with LocalDb v11.0?
Or is it possible to use official microsoft/mssql-server-linux either Linux or Windows?

I'm not aware of an official Docker image for LocalDB. You would need to build a custom (Windows) image from a dockerfile, installing LocalDB via command-line with RUN instructions. But since LocalDB does not allow remote connections, the implication is that you would also need to include your app and dependencies in the image too.
Docker CE for Windows can run either Linux and Windows containers. However, both cannot (currently) run at the same time so you'll need to toggle between the 2 image types if you use both. SQL Server Linux images are lighter weight, allow different editions, and are supported in production. Windows images are needed if you have dependencies on features only available with SQL Server on Windows or prefer a Windows OS.
For non-prod use, consider using the free Developer Edition (Linux or Windows). Developer edition has all the same features as Enterprise but may only be used for development and testing. A lesser edition doesn't provide benefit unless you need to run it in production and want to save costs.
Below are links to the Docker Hub pages.
SQL Server Windows images
SQL Server Linux images
Running either of these images with -p 1433:1433, you can use the connection string from your comment:
"Server=localhost,1433;Initial Catalog={0};User ID=sa;Password=ComplexPW!123"?

Related

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.

Features are missing installing MS SQL SERVER 2016 with SQL Server R Services using web installer and command line

I am trying to install MS SQL SERVER 2016 with SQL Server R Services using web installer and command line.
I am doing this based on this article https://msdn.microsoft.com/en-us/library/mt695943.aspx
Using same web installer, but not command line works perfectly. All desired features are there.
Problem is that command line installation installs only SQLEngine and Replication features.
Logs investigation does not help much. It seems that proper files have not been downloaded and this is the reason why they are missing
My command line is:
SQLServer2016-SSEI-Expr.exe /ConfigurationFile=C:\temp\configuration.ini /IACCEPTSQLSERVERLICENSETERMS /MediaPath=C:\SQLSetup /ENU
And the configuration file content is
[OPTIONS]
Action=Install
INSTANCENAME=MSSQL2016
FEATURES=SQL,AdvancedAnalytics
IACCEPTROPENLICENSETERMS
SECURITYMODE=SQL
SQLSYSADMINACCOUNTS="<username>"
SAPWD="%password%"
What am I doing wrong?
Update: Logs: https://dl.dropboxusercontent.com/u/3028367/20161005_093914.zip
Update 2: I think I have found the reason for missing files
When I run SQLServer2016-SSEI-Expr.exe /? I get this out put:
Optional settings for basic install
==================================
D:\Downloads\SQLServer2016-SSEI-Expr.exe [/ConfigurationFile=C:\Configuration.ini] [/IAcceptSqlServerLicenseTerms] [/Med
iaPath=C:\SqlServer2016Setup] [/ENU]
ConfigurationFile Specifies the ConfigurationFile to use.
IAcceptSqlServerLicenseTerms Required to acknowledge acceptance of the license terms.
MediaPath Location where SQL Server setup media will be downloaded and extracted to.
ENU Use this parameter to install the English version of SQL Server on a localized operating
system.
"Basic!" I need "custom" It is available with the same installer if I use UI
It seems your INI file asks SQLServer to install only few features like SQLEngine and analytics.
when you specify
FEATURES=SQL,Tools
SQL will install..
. The SQL feature will install the database engine, replication, and full-text. The Tools feature will install Management Tools, Books online, SQL Server Data Tools, and other shared components
when you specify
FEATURES=SQLENGINE,REPLICATION,FULLTEXT,CONN,IS,BC,SDK,SSMS,ADV_SSMS,OCS
It will install all the above mentioned features
so you might be missing some features due to the way you are specifying
Due to this article https://support.microsoft.com/en-us/kb/3192738 only basic installation is supported by web installer, at least at this point

Connect to localdb with sql-cli

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

Embedding SQL Server into a .NET application

Hey, I've just finished writing a VB.NET application. Now I want to package the executable and the database ofcourse into a single installer file. I tried using QSetup, InstallShield to make SQL Server embedded into the setup file, and finally after hours of try&fail I have no idea. Anyone?
You can do a rightmouse on the properties of your Visual Studio Setup Project, and then there is this button 'Prerequisites'. There you can tick 'SQL Server Express ...' Or the 'SQL Server Compact 3.5'
link to image
You're probably best off just to set the connection file directly to the mdf, and attach it when the program is run. This is easier as it doesn't require a custom setup script to install the database to the database directory itself.
Note: Consider using the Compact Version, it's smaller, people don't like a full blown engine on their computer :)
InstallShield has a concept called Setup Prerequisites where you can teach it how to install additional packages along with your own. In older versions this would happen before calling your MSI. In newer versions you can have a "Feature" prerequisite where the prereq can associated to a feature and only installed if that feature is selected to be installed and after it's been selected but still before the main activity of your MSI occurs during the install execute sequence.
InstallShield also has a pattern for executing SQL scripts against your database instance so that you can then load your database into your newly installed instance.
All of this is quite powerful but it does take a bit of digging to learn.
As far as I know, anything but the SQL Server Compact Edition (SQL Server CE) cannot be embedded into your setup, really. Microsoft doesn't want that - you need to have SQL Server Express installed separately - any other edition can't even be shipped with your software (the client must have a license and installation separately).
You can indeed distribute SQL server with your custom application:
http://msdn.microsoft.com/en-us/library/bb264562(SQL.90).aspx

Using Rails 2.x with MS SQL Server 2005

Does anybody here have positive experience of working with MS SQL Server 2005 from Rails 2.x?
Our developers use Mac OS X, and our production runs on Linux. For legacy reasons we should use MS SQL Server 2005.
We're using ruby-odbc and are running into various problems, too depressing to list here. I get an impression that we're doing something wrong.
I'm talking about the no-compromise usage, that is, with migrations and all.
Thank you,
Have you considered using JRuby? Microsoft has a JDBC driver for SQL Server that can be run on UNIX variants (it's pure Java AFAIK). I was able to get the 2.0 technology preview working with JRuby and Rails 2.1 today. I haven't tried migrations yet, but so far the driver seems to be working quite well.
Here's a rough sketch of how to get it working:
Make sure Java 6 is installed
Install JRuby using the instructions on the JRuby website
Install Rails using gem (jruby -S gem install rails)
Download the UNIX package of Microsoft's SQL Server JDBC driver (Version 2.0)
Unpack Microsoft's SQL Server driver
Find sqljdbc4.jar and copy it to JRuby's lib directory
jruby -S gem install activerecord-jdbcmssql-adapter
Create a rails project (jruby -S rails hello)
Put the proper settings in database.yml (example below)
You're all set! Try running jruby script/console and creating a model.
development:
host: localhost
adapter: jdbc
username: sa
password: kitteh
driver: com.microsoft.sqlserver.jdbc.SQLServerDriver
url: jdbc:sqlserver://localhost;databaseName=mydb
timeout: 5000
Note: I'm not sure you can use Windows Authentication with the JDBC driver. You may need to use SQL Server Authentication.
Best of luck to you!
Ben
Instead of running your production server on Linux have you considered to run rails on Windows? I am currently developing an application using SQL Server and until know it seems to run fine.
These are the steps to access a SQL Server database from a Rails 2.0 application running on Windows.
The SQL Server adapter is not included by default in Rails 2. It is necessary to download and install it using the following command.
gem install activerecord-sqlserver-adapter
--source=http://gems.rubyonrails.org
Download the latest version of ruby-dbi from
http://rubyforge.org/projects/ruby-dbi/
and then extract the file from ruby-dbi\lib\dbd\ADO.rb
to C:\ruby\lib\ruby\site_ruby\1.8\DBD\ADO\ADO.rb.
Warning, the folder ADO does not exist, so you have to create it in advance.
It is not possible to preconfigure rails for SQL Server using the --database option, just create your application as usual and then modify config\database.yml in your application folder as follows:
development:
adapter: sqlserver
database: your_database_name
host: your_sqlserver_host
username: your_sqlserver_user
password: your_sqlserver_password
Run rake db:migrate to check your installation. If everything is fine you should not receive any error message.
I would strongly suggest you weigh up migrating from the legacy database. You'll probably find yourself in a world of pain pretty quickly. From experience, Rails and legacy schemas don't go too well together either.
I don't think there's a "nice solution" to this one, I'm afraid.
Our developers use Mac OS X, and our production runs on Linux. For legacy reasons we should use MS SQL Server 2005.
We are developing on Ubuntu 8.04, but our production servers are running Linux (Centos) and we are also using SqlServer 2005.
From our experiences the initial setup and config was quite painful - it took a couple of weeks to get everything to play nicely together. However, it's all seemless now, and I find SqlServer works perfectly well.
We use the FreeTDS ODBC drivers which once configured are fine.
DO NOT run productions Rails apps on Windows - you're asking for trouble. It's fine for development but nothing more. Rails doesn't scale well on Windows platforms.
Hope that helps.

Resources