Friday, 20 May 2016

Simple Way to Decrypt SQL Server Stored Procedure

When stored procedures are created in SQL Server, their entire text body is accessible to all those who have the required permissions for accessing the data. Therefore, it becomes very easy to expose the underlying object content by creating stored procedures and analyzing it content via SQL Server Management Studio, Query Analyzer, Windows PowerShell, or any commercial utility. This data transparency, as a result, poses a risk of data compromises by the potent cyber criminals. Therefore, SQL Server developers consider encryption, the most suitable way to authenticate their data.

Need For Decrypting SQL Server Stored Procedure

Even though, encryption of stored procedures of SQL Server ensures that the objects cannot be accessed and read easily, at times it poses some issues to the users. Being a SQL Admin, I have come across many issues where the users no longer had access to their decryption script and therefore were not able to decrypt the database when required.

In certain scenarios, it happens that the administrators are handed over encrypted, SQL databases to work on. In order to work with them, the first thing that the admin needs is the encryption script and in the absence of it, the admin go for decrypting the database.

Procedure to Decrypt Stored Procedure in SQL Server

The first thing that needs to be done is to open a DAC (Dedicated Administrator Connection) to the SQL Server. It is to be noted that the DAC can only be used in three conditions:

  • The user is logged in the server.
  • The user is using a client on that server.
  • The user holds the sysadmin role.

Keep in mind that the DAC will not work if the user is not using TCP/IP and will show cryptic error if TCP/IP is not used.

The process is mainly divided into three sections:

  1. The first step is to get the encrypted value from sys.sysobjvalues via DAC connection.
  2. The next step is to take out the encrypted value of some blank procedure.
  3. Get the unencrypted blank procedure statement in plaintext format. Apply XOR to all the results. XOR is the simplest decryption procedure and is the basic algorithm used in MD5.
SET NOCOUNT ON
GO
ALTER PROCEDURE dbo.MyDatabase WITH ENCRYPTION AS
BEGIN
 PRINT ‘This is decrypted database’
END
GO
DECLARE @encrypted NVARCHAR(MAX)
SET @encrypted = (
  SELECT imageval
  FROM sys.sysobjvalues
  WHERE OBJECT_NAME(objid) = ‘TestDecryption’)
DECLARE @encrypedLength INT
SET @encryptedLength –DATALENGTH(@encrypted) / 2
DECLARE @procedureHeader NVARCHAR(MAX)
SET @procedureHeader = N ‘ALTER PROCEDURE dbo.TestDecryption WITH ENCRYPTION AS’
SET @procedureHeader = @procedureHeader + REPLICATE(N ‘-‘,
(@encryptedLength –LEN(@pocedureHeader)))
DECLARE @decryptedMessage NVARCHAR(MAX)
SET @decryptMessage = ‘’
SET @cnt = 1
WHILE @cnt <> @encryptedLength
BEGIN
 SET @decryptedChar = 
         NCHAR(
              UNICODE(SUBSTRING(
                     @encrypted, @cnt, 1)) ^
              UNICODE(SUBSTRING(
                     @procedureHeader, @cnt, 1)) ^
               UNICODE(SUBSTRING(
                     @blankEncrypted, @cnt, 1)) ^
       )
  SET @decryptedMessage = @decryptedMessage + @decryptedChar
 SET @cnt = @cnt + 1
END
SELECT @decryptedMessage

Conclusion

SQL Server database encryption ensures database authenticity from unwanted users. However, this may at times pose a problem for the user. With the help of the above-mentioned script, the user can easily decrypt their stored procedures in SQL Server. However, if the above procedure doesn’t work for you, then going with a third party SQL decryptor tool is the best solution.

Saturday, 16 April 2016

What's New in SQL Server 2016 Release Candidate 3


Microsoft announced SQL Server 2016 Release Candidate 3 Evaluations


Benefits of SQL Server 2016 Release candidate 3:

  • Enhanced in-memory performance provide up to 30x faster transactions, more than 100x faster queries than disk based relational databases and real-time operational analytics
  • New Always Encrypted technology helps protect your data at rest and in motion, on-premises and in the cloud, with master keys sitting with the application, without application changes
  • Built-in advanced analytics– provide the scalability and performance benefits of building and running your advanced analytics algorithms directly in the core SQL Server transactional database
  • Business insights through rich visualizations on mobile devices with native apps for Windows, iOS and Android
  • Simplify management of relational and non-relational data with ability to query both through standard T-SQL using PolyBase technology
  • Stretch Database technology keeps more of your customer’s historical data at your fingertips by transparently stretching your warm and cold OLTP data to Microsoft Azure in a secure manner  without application changes
  • Faster hybrid backups, high availability and disaster recovery scenarios to backup and restore your on-premises databases to Microsoft Azure and place your SQL Server AlwaysOn secondaries in Azure

For download, Microsoft reference: [Click Here]




For more updates:
Subscribe for Blog posts [Click Here]
Follow FB Page [Click Here]
Follow FB Group [Click Here]
For Suggestion & Feedback mail us at gana20m@gmail.com




Tuesday, 29 March 2016

SQL Server Failover Cluster Configuration & its Hardware Compatibility

Introduction

Failover cluster in SQL Server is a type of cluster in which two or more independent servers are interconnected with each other via means of physical cables and software. The servers in failover type of clustering are referred to as nodes. This has a major advantage of providing availability of applications and services. If one of the nodes of cluster fails then another node provides the same service.

Requirements for SQL Server Failover Cluster Configuration

The failover cluster configuration requires following necessities:

  1. Hardware Requirements
  2. Software Requirements
  3. Network Infrastructure with domain account requirements

Hardware Requirements- User requires following hardware for failover configuration in SQL Server.

  • Server: Since clustering is all about interconnected nodes, therefore we require a set of computers that consists of similar components
  • Network Communication Means: For cluster formation, the network adapters and cables are required for connecting the servers/nodes with each other and these connections should be dedicated to network communication.
  • Device Controllers for Storage
    1. For Serial Attached SCSI: If users are using fiber channels or serial attached SCSI then all the components of storage stack must be same like multipath Input Output and Device Specific Module components must be identical.
    2. For iSCSI: If the user is using Internet Small Computer System Interface (iSCSI) then each server should be dedicated to storage and should not be used for network communication.
  • Storage: Shared storage is compatible with SQL Server in failover clustering. Storage requirements include the following measures:
    1. Use basic disks for failover clustering
    2. The partition of each server’s disk done must be with NTFS.
    3. Master Boot Record or GUID partition table can be used for partitioning style of disk

    Note: The copy of the cluster configuration database is held by a disk in clustered storage and this disk is known as disk witness.

  • Deploying SAN with failover configuration: When activating a storage area network (SAN) with a failover cluster follow below mentioned guidelines:
    1. Confirming Storage Compatibility: Recheck from the vendors or manufacturers about drivers, firmware, and software (used for storage) whether they are compatible with failover clusters or not.
    2. Keep apart storage devices: The servers from different clusters must be unable to access the common storage devices. Generally, a unique Logical Unit Number is used for one set of cluster servers that should be separated.
    3. Prefer Using multipath I/O: The hardware vendor should supply a multipath Input-Output device for failover clustering.

Software Requirements- While configuring failover clustering in SQL Server the servers must either run processor supporting 64-bit operating system or Itanium architecture based versions of SQL Server. All the connected servers must have the identical same software updates along with their service packs.

The feature of failover clustering is updated in server products like Windows Server 2008 R2 Enterprise and Windows Server 2008 R2 Datacenter but not in Windows Server 2008 R2 Standard or Windows Web Server 2008 R2.

Network Infrastructure with Domain Account Requirements- Following network infrastructure is used for SQL Server failover cluster configuration.

  • IP Address and Network Settings: Ensure at the time of adapter installation that no settings are in conflict. Remember that each adapter must have a unique IP address even if they have identical physical network
  • Domain Name System: For naming resolution, the server in the cluster must be DNS.
  • Account Administering: At the time of creation of SQL Server cluster, user must be logged on domain with account that has administrator rights and permissions on every servers of the cluster. It can be Domain Users account that is in Administrators collection on each node.
  • Domain Role: All the nodes of clusters must be in same Active directory domain, possibly all nodes should have the same domain.
  • Clients: As such, no technical expertise required apart from connectors who connect the server for clustering and run softwares that are compatible with services.

Steps to Configuring Failover Clustering in SQL Server:

Follow the given steps for performing the SQL Server failover cluster configuration:

  1. Go to Administrative Tool >> Server Manager
  2. On each node of the cluster, enable ‘Failure Cluster Feature’ in all servers
  3. Click on Next >> Install and then on one of the cluster perform further steps
  4. Open Failover Cluster Management from Start >> Administrative Tool >> Failover Cluster Management
  5. On the window appearing, on the LHS of window you’ll find Failover Cluster Management there you right click on that and then select Validate a configuration
  6. Now Validate a Configuration Wizard window will display on that Enter name and Selected Server and click on Next
  7. Now choose Run all tests and then click Next
  8. Now a confirmation window appears displaying all the nodes that are connected to that particular node. Validate the information displayed on that screen
  9. Now again click on Next and then Finish.

Conclusion

We can configure failover cluster in SQL server at the time of setup installation also otherwise if necessity is after installation the article guides you for such.

Thursday, 24 March 2016

Fixing Maintenance Plan Error code 0x534



Recently I have posted a article in SQLServerCentral on Fixing Maintenance Plan Error code 0x534



Read My Article "Here" 



















For more updates:
Subscribe for Blog posts [Click Here]
Follow FB Page [Click Here]
Follow FB Group [Click Here]
For Suggestion & Feedback mail us at gana20m@gmail.com

Saturday, 16 January 2016

Troubleshooting SQL Server Operating System Error 995

Operating System Error Message

Error: 18210, Severity: 16, State:1
BackupMedium::ReportIoError: write failure on backup device ‘VDI_ DeviceID ‘. Operating system error 995 (The I/O operation has been aborted because of either a thread exit or an application request).

Reason Behind SQL Server Operating System Error 995

There are a number of scenarios when Operating System Error 995 can be experienced by SQL users:
  1. The dominant reason behind the occurrence of os error 995 is the outdated versions of SQLVDI.DLL on SQL Server 2005 or SQL Server 2000 instances.
  2. In case the database backup of SQL server exits abruptly in Activity Monitor while using the NetBackup SQL Server extension, Error 995 can occur.

Workaround To Remove SQL Server Error 995

Whenever the SQL API attempts to create a virtual device, a virtual memory or a physical memory is required for doing the same. However, with the functioning of NT file system for creation of backups, SQL services, and additional programs at the same time, the system does not end up in having enough virtual space or physical memory. When the third and the fourth database of the batch are in the process of being backed up, the NT system backup is completely processed and the memory that is to be used for creation of virtual device is freed.
The OS error code 995 can be removed by splitting the SQL database into multiple policies, which will individually backup few databases at a particular instance. In addition to this, the second method that can be used is increasing the physical or virtual memory, which can overcome this issue.

Conclusion

The above-mentioned error, SQL Server Error 995, at times leads to corruption of SQL Server database. So it is better to repair corrupt SQL .bak file using third party commercial tool.




For more updates:
Subscribe for Blog posts [Click Here]
Follow FB Page [Click Here]
Follow FB Group [Click Here]
For Suggestion & Feedback mail us at gana20m@gmail.com

Tuesday, 12 January 2016

Error: Microsoft .NET framework 3.5 service pack 1 is Required- SQL Server 2014



Read My Article "Here" 



























Ganapathi varma
Senior SQL Engineer, MCP

For more updates:
Subscribe for Blog posts [Click Here]
Follow FB Page [Click Here]
Follow FB Group [Click Here]
For Suggestion & Feedback mail us at gana20m@gmail.com

Wednesday, 23 December 2015

SQL Server 2016 AlwaysOn Availablility Enhancements


In this Article I have listed out SQL Server 2016 AlwaysOn Availability Enhancements.
SQL Server 2016 [CTP 3.2] SQL Server 2016 CTP Standard Edition now supports AlwaysOn Basic Availability Groups.
AlwaysOn Basic Availability Groups replaces the deprecated Database Mirroring feature for SQL Server 2016 Standard Edition. 
AlwaysOn Basic Availability Groups provide a high availability solution for SQL Server 2016 Standard Edition or higher.
To create a basic availability group, use the CREATE AVAILABILITY GROUP transact-SQL command and specify the WITH BASIC option (the default is ADVANCED). 
A basic availability group supports a fail-over environment for a single database. It is created and managed much like traditional (advanced) AlwaysOn Availability Groups (SQL Server) with Enterprise Edition. 
Basic availability groups enable a primary database to maintain a single replica. This replica can use either synchronous-commit mode or asynchronous-commit mode

Limitations of Basic availability groups

  • Limit of two replicas (primary and secondary).
  • No read access on secondary replica.
  • No backups on secondary replica.
  • No support for replicas hosted on servers running a version of SQL Server prior to SQL Server 2016 Community Technology Preview 3 (CTP3).
  • No support for adding or removing a replica to an existing basic availability group.
  • Support for one availability database.
  • Basic availability groups cannot be upgraded to advanced availability groups. The group must be dropped and re-added to a group that contains servers running only SQL Server 2016 Enterprise Edition. 


Load-balancing of read-intent connection requests is now supported across a set of read-only replicas. The previous behavior always directed connections to the first available read-only replica in the routing list. 
The number of replicas that support automatic failover has been increased from two to three.
Group Managed Service Accounts are now supported for AlwaysOn Failover Clusters. 
AlwaysOn Availability Groups supports distributed transactions and the DTC on Windows Server 2016.
You can now configure AlwaysOn Availability Groups to failover when a database goes offline. This change requires the setting the DB_FAILOVER option to ON
SQL Server [CTP 2.2] AlwaysOn now supports encrypted databases. The Availability Group wizards now prompt you for a password for any databases that contain a database master key when you create a new Availability Group or when you add databases or add replicas to an existing Availability Group.



Reference: BOL





Regards,
Ganapathi varma
Senior SQL Engineer, MCP
Email: Gana20m@gmail.com