Adding encrypted columns to a SQL Server database with always encrypted on - sql-server

I have a SQL Server database, with always encrypted on. I am using command line sql (T-SQL) to update the database, and I want to add a column. I can't find the syntax for adding a column that is marked as encrypted.
I know I can add the column and then use SQL Server Management Studio to set it to encrypted, but I really want to do it in a batch job, hence the T-SQL commands.
Any ideas?

There's no TSQL API for it by design:
You can perform the above steps using SQL tools:
SQL Server Management Studio (SSMS)
SQL Server PowerShell
sqlpackage - which automate the setup process
To ensure Always Encrypted keys and protected sensitive data are never
revealed in plaintext to the database environment, the Database Engine
can't be involved in key provisioning and data encryption, or
decryption operations. Therefore, Transact-SQL (T-SQL) doesn't support
key provisioning or cryptographic operations. For the same reason,
encrypting existing data or re-encrypting it (with a different
encryption type or a column encryption key) needs to be performed
outside of the database (SQL tools can automate that).
Always Encrypted

Related

SQL Server Backend, Access front end connection question

I transferred my Access Back-end to SQL Server and linked the tables. I used the SQL Server Migration Wizard. When I ran my Forms, Reports and Queries, I was surprised to see that it worked perfectly fine as if I did not even migrate.
How is it the JET SQL syntax of Access able to retrieve data from SQL Server which uses T-SQL language?
Because Jet doesn't need to use Transact-SQL, it just knows how the data is stored, the same way you can use an ODBC connection to pull data from an Oracle database without using PL-SQL. Also, you can write a stored procedure in the SQL database, using T-SQL, and you can fire it off via Jet: the proc lives and runs on the SQL side, and Jet doesn't need to know how it works, just how to fire it.

Always Encrypted feature in SQL Server 2016 CTP2, how Studio Management work?

On this page What's new in the .NET 2015 RC I found this
Always Encrypted secures customer data so DBAs do not have access to plain text data.
And I wonder how a developer can check the data in db by using SQL Studio Management ? Is it still displaying plain data like Version 2008?
A developer can access plaintext data if he has access to the Column Master Key. If you have access to Column Master Key, you can follow this MSDN article to configure SSMS to decrypt data. The latest version of SSMS also allows you to insert, update and filter encrypted data.

Compare SQL Server Database Schema with Oracle Database Schema

in my development environment we support the application both on MSSQL Server as well as Oracle. The database schema of both of these RDBMS are same.
while development we found that the developer made a mistake and forgot to change the oracle database for the last 1 yr. therfore the oracle script is quite behind in term of schema from SQL Server schema script.
now the question is how i can compare the two RDBMS systems to find the difference and make the oracle script updated
If there are no track log from which it's possible to find and reproduce all changes applied to SQL Server since first detected inconsistency with Oracle version, or that changes was applied, but only partially, you really need to compare objects presented in both databases.
In this case setup a link between databases on any side and use system dictionary views to compare table structures and other objects to find differences and, possible, to generate script for Oracle scheme rollup.
If you want to act from MS SQL Server side:
Install and configure Oracle Instant Client
Install Oracle ODAC
Follow Microsoft recomendations (64-bit version)
Connect as any user with dba role (or use same Oracle schema where object resides) to Oracle from MS SQL database
If you want to act from Oracle Server side:
Install and configure Oracle Database Gateway for SQL Server.
Create database link to MS SQL Server.
After successful configuration you may join Information schema views on SQL Server side with Data dictionary views on Oracle side to find differences.
Of course there are many troubles at this way like different data types, but it gives a chance to automate at least part of work.

How to Import Oracle .DMP file into SQL Server?

I have a .dmp file (oracle data) and I have to import this file into SQL Server 2008 R2. I tried google but get no clear solution. Oracle is on other machine and SQL Server is on other machine. This .DMP file has only tables and data only nothing else.
Any body has any idea?
You can't get there from here. The files that the Oracle export utility (classic or DataPump) generate (which, by convention, frequently use the DMP extension) are proprietary binary files. They can only be consumed by the Oracle import utility (classic or DataPump) which will only allow you to load the data into another Oracle database.
You could load the DMP file into a new Oracle database but then you'll still need to move the data from Oracle to SQL Server. It may well be easier to ignore the DMP file and pull directly from the original Oracle database. There are a variety of tools that can be used to move data from an Oracle database to a SQL Server database. If you want SQL Server to control the process, you could SQL Server Integration Services (SSIS). You could also create a linked server in SQL Server that references the Oracle database and write queries against the Oracle database via that connection. If you wanted Oracle to push the data, you could also use the Oracle Transparent Gateway with Heterogeneous Services to create a database link from Oracle to SQL Server and issue SQL against the remote SQL Server database.
There is a nice StackOverflow thread on moving data from Oracle to SQL Server. The SSIS logic is extremely similar if you're pulling from Oracle to SQL Server or pushing from SQL Server to Oracle.
Oracle Dumps is not readable by SQL.
Simply it cannot be, But you have different solutions
SQL server integration services (SSIS)
Link between oracle and SQL (Oracle Gateway) but it works with SQL Ent.
Export the data from oracle in a delimited format and insert it into SQL, but it will takes time if data is huge.
When I faced with the same problem, I tried to investigate the format manually (in my case the dump file was generated by Oracle EXP). I found that:
Table definitions come as Oracle CREATE TABLE statement that can be converted into MS SQL format easily
Most kind of data ca be extracted quite easy (text goes "as is", numeric values are stored according to IEEE 754 format)
LOBs are stored in quite complicated way, I failed to recognize it
Then I found the tool that was able to do my migration task: https://www.convert-in.com/ord2mss.htm
Vendor said that it can migrate both exp and expdp to sql server, but I have tested it on EXP format only.

best way to store data in wpf application

i just want to know about the best way to store sensitive and secured data in wpf application that will not appear inside the exe file like databases and will store data and retrieve it when program start up again
Going by the latest comment, it seems that you need to encrypt user input data. Depending on the size of the data you could go with SQL Server 2008 R2 Express or SQL Server Compact. You can have a look at SQL Server 2008 R2 CE encryption or SQL Server 2008 R2 Express encryption.
If you are not looking at databases, then you could have a look at file based encryption using the System.Security.Cryptography namespace.
Higher levels of security are available in the enterprise version of SQL Server. More information on encryption levels in SQL Server 2008 can be found here.
Note that encryption of the database (depending on the algorithm used) can negatively affect the performance.

Resources