How to Encrypt and Decrypt String in Sql Server

How to Encrypt and Decrypt String in Sql Server

I recently got a request to obfuscate data at Dev environment.  Most of the times these kind of requests come in environments where dealing with sensitive data. We usually do dev refresh from prod on monthly basis to make sure both at sync. So whenever a refresh happens we need to obfuscate sensitive data at Development environment.

Obfuscation is nothing but replacing the original data with dummy data. There are few options / native methods available in SQL Server. I preferred the below methodology.

Here I am just giving an example using a variable; we can follow the same methodology while dealing with tables.

How to Encrypt and Decrypt String in Sql Server:

/*****************************************************/

/*** @pwd - Generate a random pwd every time *********/
/*** Always operate these things from DBA database ***/
/*****************************************************/

DECLARE @pwd            NVARCHAR(100),
        @txt            VARCHAR(30),
        @EncryptedText  VARBINARY(1000);

SELECT  @txt ='ACCNO-NYCITI-01678999',
        @pwd = N'ObIhkju8-9m64Gbn';

SELECT @EncryptedText = ENCRYPTBYPASSPHRASE(@pwd,@txt)
SELECT @EncryptedText AS 'Encrypted Text'
SELECT CONVERT(VARCHAR(30),DECRYPTBYPASSPHRASE(@pwd,@EncryptedText))
AS'Original Text

OutPut:

Note: While decrypting it must be converted as varchar

 


Posted in SQL Development, SQL Server DBA | Tagged , , , , , | Leave a comment

Cumulative update package 4 for SQL Server 2012 is available

 
 

 

Cumulative update package 4 for SQL Server 2012 is available

How to obtain Cumulative Update 4 for SQL Server 2012

A supported cumulative update package is now available from Microsoft. However, it is intended to correct only the problems that are described in this article. Apply it only to systems that are experiencing these specific problems. This cumulative update package may receive additional testing. Therefore, if you are not severely affected by any of these problems, we recommend that you wait for the next SQL Server 2012 service pack that contains the hotfixes in this cumulative update package.

If the cumulative update is available for download, there is a “Hotfix download available” section at the top of this Knowledge Base article. If this section does not appear, contact Microsoft Customer Service and Support to obtain the cumulative update package.
More Info

Posted in Miscellaneous | Tagged , , , | 1 Comment

Register for Windows 8 Event for IT professionals

 

It gives us great pleasure to invite you to exclusive events for
IT professionals, where Microsoft Experts would take you
through the latest Technologies of Microsoft including Windows 8 & Internet Explorer 10. They will give you insights into the benefits your organization can draw from these new technologies.
LEARN ALL ABOUT:
Internet Explorer 10
Windows 8 Enterprise features
Windows Server 2012
Enabling Flexible Work style
EVENT DETAILS:
Date City Address
08th October
2012
Bangalore Le Meridien
28, Sankey Road, Bangalore
Ph : +91-80-2226 22 33/ 2228 28 28
09th October
2012
Hyderabad Katriya Hotels & Towers
Raj Bhavan Rd, Somajiguda, Hyderabad
Ph : +91-40-23325678 / 4066135678
11th October
2012
Chennai Ambassador Pallava
Montieth Road, Egmore, Chennai
AGENDA:
Time Session
1.30 pm – 2.00 pm Registration
2.00 pm – 3.15 pm Windows 8 & IE 10 in the Enterprise – Enabling Flexible Workstyles
3.15 pm – 4.30 pm Windows 8 & Windows Server 2012 – Better together
4.30 pm – 5.00 pm High-tea

Microsoft respects your privacy. Please refer to our online Privacy Statement.

Microsoft Corporation (India) Pvt. Ltd.
9th Floor, Tower A, DLF Cyber Greens, DLF Cyber Citi, Sector 25A
Gurgaon, Haryana 122 002 INDIA

Posted in Miscellaneous | Tagged , , , , | Leave a comment