How do I deploy a compiled database that no one can see/view source script but can execute it - sql

I developed an application that used SQL Server database 2017. I wrote most of the business logic in stored procedures, triggers & UDF. Now at the time of Go-Live, I want to deploy a compiled database on a client-server machine so no one can view or change scripts.
I can manage this from the SQL Security, access rights, etc. but actually, the Client network administrator has all the credentials and rights of the database and I do not want anyone to view/change the script even the administrator.
can I deploy a compiled database on a client-server instead of a regular one so no one can view/change scripts but can execute them Similarly like EXE file users can execute it but cannot view/change the code?
Does Microsoft SQL Server provide a solution on this or any workaround?
please suggest thanks in advance.

Related

Click-once SQL Server Express deployment

We are developing a small application that needs to have a local database installed on each users computer that will then sync up to the main database, via web services etc...
Anyways when we deploy the application on the users computer we want to use clickonce deployment. Now I have used this before but not attaching a SQL Server database. I know you can go to prerequisites in clickonce properties and click SQL Server Express.
Now the question is, when you have created your .mdf database file including stored procedures and all - how do you get this attached and setup automatically in the local database that is just installed through clickonce?
Also once this is finished in the future we may want to run updates to the database on the clients machines. We would like to use clickonce for this to publish database updates. Obviously we don't want to overwrite the database and just publish the latest updates based on if they already have the database or not and what version they have.
How could this be achieved using clickonce? Thanks

VB.NET Creating a local database in VS2013 or in SQL Server Management Studio

I am about to begin a personal project to build my skills in the .net environment. I am familiar with SQL Server Management Studio and how to create a database in it but I discovered how to make a local database in Visual Studio as well. My program is only going to require local database access as it will be used for individual inventory systems rather than connected ones. Am I ok to use the onboard tools in visual studio and create a local databasse or should I be using the SQL Server Management Studio?
When you use the Local Database item template in VS, it creates a SQL Server CE data file (SDF) and adds it to your project. When you use the Service-based Database item templete, it creates a SQL Server (Express) data file (MDF) and adds it to your project.
The advantage of using the VS tools is that the data file becomes part of your project and can therefore be easily deployed with the compiled application. As such, the database is basically part of the application.
If you choose SQL Server CE then you don't need a server installed on the user's local machine. They can install SQL Server CE or you can install it with your app if you want, but you also have the option of simply deploying a DLL with your app and it will work.
If you choose SQL Server Express then the user actually needs a SQL Server instance installed on their machine. To be honest, I'm not 100% sure whether that instance must be SQL Server Express or it can be a full SQL Server instance too. It would usually be SQL Server Express though, which you can install and even download automatically when you install your app, depending on the deployment method you choose.
If you use the VS tools to create an MDF data file then your connection string will contain the Data Source and AttachDbFilename attributes. The Data Source will generally be ".\SQLExpress", i.e. an instance named "SQLExpress" on the local machine. That instance name is not required, although it is the default for SQL Server Express, but it must be on the local machine. The MDF file gets attached at run time and detached again when you're app is done with it. It will also usually be attached to a user instance, which means that other users can't see it, even when it's attached. Note that, in later versions, the LocalDB feature of SQL Server may also be utilised.
If you create your database in Management Studio then it's not actually part of your app. It will be permanently attached to the SQL Server instance so, everyone will be able to see it and open it, assuming permissions allow. Creating the database during deployment will be an extra step in that case. You might create a backup and restore that during deployment or generate SQL scripts that get run. In this case, your connection string will contain the Initial Catalog attribute to specify the name of database to connect to, as well as the Data Source attribute. This option is required if you want multiple clients to be able to connect to the database.
In short, if you are only going to be accessing a database from the local instance of the one application then creating a database in VS is OK and probably a good idea. Whether you choose SQL Server CE or SQL Server Express may well depend on what level of functionality you need.

SQL visual client to query a databse deployed at heroku

I know Heroku has a command line client to execute a .sql file.
But is there something like an SQL Server Management Studio for databases deployed at Heroku? I was looking for a UI that allows you to interactively write queries, execute them, and view the results on a grid. I'll mostly execute SELECTs and UPDATEs based on ids, over databases generated by Rails.
Have a look at Adminium: it's a free control panel plugin for Heroku.
https://addons.heroku.com/adminium
Take a look at http://www.pgadmin.org/ and install pgAdmin III. I use it for the same purpose, watch and query over the database of one of my Heroku apps.

MDF file security, lock and unauthorized access

I used SQL Server 2008 R2 database in my application, now I want to install the application for my friend. How can I block access to my database tables and stored procedures ?
I removed Windows authentication and SQL Server Management Studio just login with my own user or pass ! But what happen if he opens my database file in other Management Studio in other systems?
Your users should not have access (ACL permissions) to MDF files, ever. Not at all. They should, instead, have database access, and their account should be set to do what you want them to do, and not to do what you don't.
This is a pretty basic question, really; what you need to look into is SQL Server security, so you can figure out how and what to secure your database with users. But you also need proper file security, as I noted above.
Finally... your question makes me wonder; you do know that SQL Server is not necessarily meant to be installed on every single client system, right? You certainly can do that, but it's a server product. If you are installing it on a computer to which the user has admin rights, the game is pretty much over, really.

Visual Studio database project won't deploy to SQL Azure

I've ran into problem very similar to this. I have a .dbproj Visual Studio database project. It deploys just fine in SQL Server Express. Now I want to deploy it to SQL Azure - I change the connection parameters but deployment fails with the following text:
C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\TeamData\Microsoft.Data.Schema.TSqlTasks.targets(120,5): Error Deploy01234: The target database schema provider could not be determined. Deployment cannot continue.
Done executing task "SqlDeployTask" -- FAILED.
Is deploying .dbproj projects to SQL Azure supported? How do I make Visual Studio deploy the database into SQL Azure? What are other ways to achieve more or less the same results except recreating the database manually using Azure portal?
If you are using Visual Studio 2012, you can now create a Database project and go to Properties - set its Target Platform to SQL Azure in Project Settings tab. Also you can configure the setting for dacpac output. Use this file to import directly as a new SQL Azure database.
As far as I know, Database projects are still not supported by Windows Azure. You can deploy the project to a local SQL server and then use the "Generate Scripts" feature to port the database to SQL Azure. See this link.
An easy solution is to create the database locally and use the SQL Azure Migration Wizard to do the migration up to SQL Azure. It works very well in just a few clicks (and will fix common errors).
Database projects don't work with SQL Azure. What I do is before deploying, create a brand new database on local server (to ensure it is up to date with no dev scripts), and then sync that database to Azure with RedGate SQL Compare. I do a backup first with RedGate SQL Azure Backup.
When we first built DB projects, SQLAzure was still going through its identity crisis and didn't know what it wanted to be. ;)
DBProjects support a significant superset of capabilities vs. SQLAzure. Therefore, it's quite possible that it'll create scripts that won't run against SQLAzure.
I know that the team who took-over the DBProject tooling were looking at restricting the database project generators to output SQLAzure-compatible scripts, but I don't know how far they got or whether they decided to proceed.
I echo dunnry's suggestion above and use the SQL Azure Migration Wizard or Jeremy's and use SQL 2008 R2 and generate Azure-compatible scripts.