Wednesday, 23 May 2018

Tips for Securing SQL Server Database from All Sort of Risks

Securing SQL Server Database is a challenging task as there are number of external and internal risks or parameters affecting the Server and its databases. In this section, we have discussed about all the concepts and the precautions that can be taken to prevent databases and the accumulated components such as tables, stored procedures, triggers, etc. To protect the SQL DB, it is mandatory to provide security to the overall SQL infrastructure. Therefore, this approach is divided into given segments;
  •  Platform Security
  •  Application Security
  •  Database Security
Let’s discuss about these parameters in detail, so as to get better understanding on all the perspectives that can help safeguard crucial information existing under SQL environment.

      Platform Security:

Platform security of the database refers to securing the hardware components from outside risks. It can be done by proposing access limitations for SQL Server to the few and authorizing users.  It is recommended to store the backup media at some offsite location with secure and minimal access. This can be done by configuring least users with access authorities and controlling unauthorized access on network devices and components.
The integral components such as Operating System and associated files can be protected by referring to the below mentioned measures;

Method 1:

Update Notifications: The internal security of the SQL Server Operating System can be ensured by installing genuine applications. After installing any new application or software in SQL Server, do always remember to update the associated notifications and security enhancements received from Microsoft.

Note: This can alternatively be done while installing SQL Server 2014 by checking the associated checkbox in the set-up window.



Method 2:

Keep Firewalls On
: By keeping the Firewalls On, the security measures can be increased to ensure extended security. Firewalls are considered the security system that controls the network traffic by applying defined set of rules. It serves as the barrier between secure network (such as home network) and the external network such as internet (that might not be secure or fully trusted).



        Application Security:

Since SQL Server relies upon systems’ files in order to store data components so it is important to limit the access to these files for assuring more data security. This can be done by implementing the following given methods;

Method 1:

Access Authority: By assigning access restrictions to the distinct users existing on database, the files can be prevented from any unauthorized access. By doing so, the files can only be accessed by the users who are marked eligible to access them by the Database Administrator.



Method 2:

Authentication Check: Another powerful method to protect the integrity and security of data is via assigning strong passwords to the important files. This method can be implemented in a powerful manner when used with the combination of access authorities.


        Database Security

Now the most powerful aspects comes i.e. the SQL Database and the incorporated objects such as data stored in tables, stored procedures, indexes, triggers and all other components. Following concepts can be utilized for securing SQL Server and the data components from all sorts of internal and external factors.

Method 1:

Regular Backup: It is recommended and even serves as a best practice to backup SQL database and system log files on regular basis so as to avoid any data loss. Backup approach provides full security over data as if entire database or any of its components becomes inaccessible due to corruption or any other reason, the lost data can be gained back via backup restoration.

Note: Sometimes user forget to take regular backup or scheduled backup.In that case, if any database corruption occur or any accidental deletion of data occur, the chances of data loss becomes quite high. So in that case, you can use SQL Database Recovery Software for repairing and recovering of your SQL Server Database.

Method 2:

Data Encryption: The most powerful way to safeguard data and all encapsulated elements is via encrypting the files or the segments of data. However, this approach will not help in controlling the access over database but in case if the crucial information is leaked out via any unknown resources; it will not put any adverse effect on the data or the concerned person (to whom the particular information belongs to).



Conclusion:

Since the information existing into SQL databases is crucial as it includes data associated to many users or individuals. It is important to protect it from unauthorized access and illegal interruptions so as to avoid the occurrence of adverse circumstances. Using either or all of the above stated tips to secure SQL Server Database, the entire infrastructure, the application or the encapsulated data can be protected from distinct kinds of risks factors.

Monday, 21 May 2018

Tactics to Find Outdated Statistics in SQL Server

Statistics in SQL Server are used to identify the type of plan that needs to be executed for a query. SQL Server is pretty good in estimating the statistics. But, there are some circumstances in which it does not, in that case, a better understanding of statistics is required. Moreover, how SQL Server finds outdated statistics in SQL Server is also important to resolve the performance problem. If a user is not having good command on statistics, then it is difficult for a user to handle queries without having proper indexes. Thus, in this post, what exactly is SQL Server Statistics and how to find the outdated statistics in SQL Server is discussed to improve the SQL Server performance.

What is SQL Server Statistics?

In simple words, statistics in the SQL Server are the base on which the indexes are built. If there are no accurate statistics, then the indexes simply do not work and moreover, the good execution plans is also not created. It is generally used by the query optimizer to determine an accurate execution plan for a particular column.

The statistics, which are collected by the SQL Server are the number of different values that occur for a given column or a set of columns. In addition, after sampling the data in the table, SQL Server identify the statistics. But, it all depends on the size of the table whether it has to sample large or small percentage of the rows.

For example, assume that a user is having a column in a table in which all responses of MCQ question are stored. In it, one-fourth of the values are A, half are B, and the another one-fourth are C. however, it can also be possible that SQL Server will have a look on only one percent of the rows and comes up with three different values. It is because the server has correctly estimated the number of different values and give correct results. So, for a large amount of data low sampling rate is always a good idea.

Method to Check SQL Server's Statistics

As everyone is making SQL Server at different rates and perform the comparison of those samples, then it becomes possible to determine how the computed density changes with the sampling rate. In particular, one can easily compare the default sampling rate of the SQL Server with the actual statistics. After comparison, the result will determine whether the SQL Server handle the updating of statistics or if one needs to create his/ her own statistic update scripts. Now, to perform comparison process, follow the steps given below:

  • First, you need to identify all the statistics for a particular database by executing sp_autostats command on each table
  • After that, execute the UPDATE STATISTICS on all tables with the help of default sampling rate
  • Now, to record the estimated density values, run the DBCC SHOW_STATISTICS for every statistic
  • Then, execute the UPDATE STATISTICS command along with the FULLSCAN option on each table
  • Now, to record the actual density values, use DBCC SHOW_STATISTICS
  • Now, compare both the estimated values & the actual values. If the density varies by a large amount, then one cannot use the SQL Server default statistics routines

From the above procedure, it is pretty much clear that, if there is a non-avoidable difference in both actual & estimated density value then, SQL Server statistics are outdated and needs to be updated quickly.

The Bottom Line

Statistics in SQL Server are very important from the performance point of view. It has a direct impact on the performance of the SQL Server. If the statistics are outdated then, it will degrade the performance really fast such as bad execution plan. Therefore, a manual method to find outdated statistics in SQL Server is covered above. It is simple to execute and does not take much time. One simply use it and identify whether they are working on outdated statistics or not.

Monday, 7 May 2018

Know About SQL Server Error 6401

Introduction

The ACID acronym standing for Atomicity, Consistency, Isolation, and Durability are the properties of SQL transactions. Transactions are used when the database has to be modified by using one or more SQL statements and to make sure the security of the database as well. However, at times, this normal functioning of the transactions may pose unexpected errors that disrupt the performance of transactions.

This blog is the outcome of several queries that I’ve come across regarding SQL Error 6401. Therefore, here is a complete article dedicated to SQL Server Error number 6401.

SQL Server Error 6401

While running transactions in SQL server, the user gets an option to nest them. However, care should be taken that the number of COMMIT TRANSACTION and BEGIN TRANSACTION should be same. The number of BEGIN TRANSACTION commands can be known by running global variable @@TRANCOUNT. SQL Server Error 6401 basically occurs during the rollback transaction of nested transactions. Rollback transaction enables user to bring back the SQL database in its original state. However, this is not possible when the Nested transactions are concerned.

Multiple rollbacks in case of nested transaction are not possible and hence when run, gives the following error:

Msg 6401, Level 16, State 1, Line 33 Cannot roll back Inner Transaction. No transaction or savepoint of that name was found.

The error encountered clearly specifies that the user has tried to do multiple rollback in nested transaction.

In the example, shown below, the user has created nested transaction in which the outer transaction is being denoted by outerTran and the inner transactions are denoted by innerTran

In the highlighted section, you will be able to see that a ROLLBACK TRANSACTION on the innerTran has been carried out. When this query is run, the SQL Server Error 6401 is encountered by the user.

How To Remove SQL Server Error 6401?

There are three possible ways by which Error 6401 can be prevented from occurring. They are as follows:

  • Using ROLLBACK TRANSACTION statement without specifying the name of the transaction.
  • Replace BEGIN TRANSACTION statement with SAVE TRANSACTION statement.
  • Using third-party SQL Server Log File viewer software.

Conclusion

SQL Server Error number 6401 is a result of ROLLBACK TRANSACTION done in a nested transaction. The best method to avoid the error has been specified in the above section. In case, the error has already been encountered, the complete transaction will have to be run again and care should be taken while doing this.

Sunday, 29 April 2018

A Perfect Solution to Resolve SQL Server Error 211

SQL Server Schema is basically a collection of SQL Objects that includes the tables, related columns, its entries, or other components. Due to this, it becomes easy for a user to access the database in the more reliable and effective way. However, there are some situations such as destruction in the schema due to which different type of errors occurs in SQL Server. This can also lead to corruption in structure or other components of the database. Among all one such error is SQL Server 211 that occur whenever there is an update in SQL Server table or when there is a corruption in SQL Server Schema. Thus, in the following section, all possible reasons for corruption in the server Schema with possible solutions to resolve this error is covered.

Error Message:

An error can occur in SQL Server in many different ways. For example,

    Error: 211, Severity: 23, State: 51. Possible schema corruption. Run DBCC CHECKCATALOG Msg 211, Level 23, State 157, Line 1 Possible schema corruption. Run DBCC CHECKCATALOG.

This type of error message generally occurs when a user tries to update a table in the database and in between the schema corruption occurs. Moreover, this error mainly occur in SQL Server 2005 and later versions. However, due to this SQL Server error 211, one is not able to open any SQL Server table.

Causes of SQL Server Error 211

The schema corruption in SQL Server database occurs very rarely. However, when this error occurs, one must have to check for the main reason behind the occurrence of this error, either through SQL error Log files or through some other source.

Therefore, all the major reasons due to which schema gets corrupted are listed below:

  • One of the major issues behind corruption is hardware failure
  • Software failure sometimes also leads to corruption in Schema
  • It can be due to any improper computer activities by server users

Manual Methods to Resolve SQL Server Error 211

There are many different manual solutions available to resolve this error. One can try any of them to fix the schema corruption that is present within the server. Thus, all possible solutions to resolve this error are:

  • Restoring the backup file of the database is one of a preferable solution to resolve this error. Now, to do the same follow the situations mentioned below:
    1. In the case of backup of the transaction log, a user can take a backup of tail-log. After that one can restore the backup completely including all transaction logs, which are ending with tail-log backup. In this case, there will be no loss of data.
    2. In the case of no transaction log backup, one can create a new database and try to import as much data as possible. However, if the user is able to identify the culprit table, then drop that particular table & create it again.
  • Another possible solution to resolve SQL Server error 211 is that a user can try is restore the complete MDF database file and deploy the database again.
  • If any of the above does not work perfectly then, in last a user can run the DBCC CHECKCATALOG command on the server screen.

After executing this DBCC command an error is displayed. However, there are some exceptions that might encounter while executing the Transact-SQL statement with dedicated Schema.

A user will possibly get some suitable suggestion from SQL server database after executing DBCC CHECKCATALOG syntax. This will let users identifying the location and reason behind the occurrence of SQL server error 211.

Effortless Solution to Remove SQL Server Corruption

Most of the times it can be possible that manual method to resolve SQL Server error 211 is failed. Apart from this, the manual procedure is a very time consuming and complex to use. Therefore, to have a trouble-free solution, a user can go for a third party solution i.e. SQL Recovery Tool. This software removes all type of corruption from SQL Server database file in an easy and simple way. One can use this tool without any hassle as the software provides an easy user interface.

Conclusion

SQL Server error 211 is the type of error due to which a user is not able to open any table in SQL Server. Therefore, to remove this hurdle, we have discussed some manual tricks to resolve this error. One can try any of the above discussed manual ways to resolve this error. Apart from this, the best possible solution to remove the corruption from SQL Server Schema is a third-party tool i.e. SQL Server database recovery tool. The tool will remove all type of corruption from SQL Server database file in just a few clicks.

Thursday, 26 April 2018

Top 5 Features of SysTools SQL LDF Recovery Software - Review

An SQL Server Expert Thoughts : I would like to recommend my readers to use SysTools SQL LDF recovery software for viewing transaction log file of SQL Server 2016, 2014, 2012, 2008 R2 database, and 2005. It is so because I personally had used this application for resolving many problems related to the SQL Server log file and all issues were rectified easily by help of this tool.

Currently, I am the database administrator in an organization where weekly I have to analyze all the SQL Server transactions made by users. Therefore, I researched for an application by which I can view transaction log of SQL Server because manual approach was not proving itself worth for my need. Through my searching process, I came across SysTools SQL LDF Recovery software, which was the one that an expert will always recommend after using it. Its interface, working, and features all are designed to achieve task of reading and viewing LDF file records with/without SQL Server. In this page, I am going to share my review on the SQL LDF reader tool and hence, one will came to know why I am suggesting this product.

SQL LDF Recovery Software – A Quick Overview

The tool enables users to connect with the SQL Server database through valid credentials for automatically extracting database with its complete records. One will be able to determine insertion, updation, and deletion record of the Server transaction, which will help in detecting major cause of the corruption in the SQL Server. The log file related attributes like Transaction, name, time, query, and table name all will be previewed on the software panel. SQL LDF Recovery software is capable of supporting all data types like Geometry, sql_variant, datetimeoffset, datetime2, hierarchyid, and geography data type. Apart from all this, the software provides feature to filter and export transaction information directly into the SQL database Server, its compatible script, or in CSV file format.

Commendable Features of SQL LDF File Recovery Software

  1. Two Modes to Browse Database Records : There are following two options to add SQL Server log files in the software:
    1. Online Mode : One just need to mention the Server credentials and database name whose transaction are to be viewed by them.
    2. Offline Mode : This option is for loading transactions from the LDF and corresponding MDF file, which is manually browsed by a user.
  2. Preview All SQL Transactions Log Activities : SQL Server LDF reader thoroughly scans the data and loads it on preview window. The tool will generate preview of all transaction activities, which are either saved on the mentioned Server or in log file. One will be able to track records with Login name authentication for operations like delete, update, and insert with other respective details.
  3. Options to Export SQL Transaction Log : Not only viewing and analyzing of transaction details but, SysTools SQL LDF recovery software permit users to import records in following three options :
    1. SQL Server Database : Option to directly export data to the SQL Server database, which requires the Server name, name of database, user name, and password.
    2. SQL Server Compatible Scripts : Choose a location where you want to save .sql file on your local machine for storing log details.
    3. CSV File : Alike SQL Server compatible scripts, you can save the log file in CSV file format.
  4. Export Selective Tables From Browsed File : Instead of exporting entire records, SQL Log file viewer provides feature to export desired Server tables, based upon certain time duration or date-range. In addition to this, one can check/uncheck tables, which they want/do not want to export in SQL Server database, or save in SQL script/CSV file format. Moreover, an option is provided to save complete export details in CSV format for future reference.
  5. Retrieve Database of Recent Editions : Examined transaction log file of the SQL Server can be used to recover corresponding damaged/corrupted database. The SQL Log analyzer tool is supportive with all versions of the Server, including its latest one. If the database is in Simple recovery mode then, one will be able to recover lost records too. Please remember that data should be exported on some other location for avoiding overwrite activity of the existing database.

SQL LDF Viewer Tool : Its Availability

There are two versions of this application, which are described below:

Free SQL Server Log Explorer : The software is available in trial version with help of which users can test and examine the functioning of it. One will only be able to view transaction log through this versions and need to purchase full version of the software for complete working.

SQL Log Analyzer Full Version : The application is available in licensed and full version with which users can preview and export transaction log files. After purchasing the product, a person will be provided with a software key to activate the full version.

SysTools SQL Log File Reader : Its Pros and Cons

Pros

  • Extract transaction details directly from the Server
  • Option to perform sorting based on log file components
  • Feature to expand multiple secondary database files
  • Compatible with all editions of Windows and SQL Server
  • Extract and view records from Live SQL database
  • Support to Analyze ldf file of SQL Server 2016, 2014 & below versions

Cons

  • In offline mode, tool supports only one LDF file at a time

Time to Wrap Up

I would like to rate this product 9.8/10 just because of only one con, which I have already mentioned. Apart from this, all other functioning of SysTools SQL Server Transaction Log recovery tool is outstanding and spending money on it, is of full worth.

Saturday, 7 April 2018

Brief Description about SQL Server Encryption

Encryption is a good technique using which a particular data is obfuscated with a key or password. This makes the data useless until any decryption key or password is used to unlock it. Encryption makes data secure and prevents data loss, even if access controls are bypassed. Users can use encryption in SQL Server for connections, stored procedures and data.

In SQL Server data is encrypted by hierarchical encryption and key management infrastructure. Each encryption layer is used to encrypt the layer below it by using asymmetric keys, symmetric keys, and a combination of certificates. Both Asymmetric keys and Symmetric keys are stored outside of SQL Server in an Extensible Key Management (EKM) module.

Below given figure shows how encryption hierarchy plays its role and encrypts a database. Here PW denotes the password.

Note: Encrypt data using symmetric keys instead of asymmetric keys and certificates for better performance.

Outside the SQL server, an EKM module holds both the symmetric or asymmetric key.

Service master key protects database master keys. The SQL Server setup creates service master key encrypted by DPAPI (Windows Data Protection API). The Service Master key and Database Master keys, are all symmetric keys.

Mechanism of Encryption:

SQL Server provides the following types of Encryption Mechanism.
  •  Transact SQL-functions
  •   Asymmetric Keys
  •   Symmetric Keys
  •   Certificates
  •   Transparent Data Encryption

Transact-SQL Functions

Using transact-SQL functions, user can encrypt individual data items while they are inserted or updated. For more information, see ENCRYPTBYPASSPHRASE (Transact-SQL) and DECRYPTBYPASSPHRASE (Transact-SQL).

Certificates


Certificates that are often called the Public Key Certificates, is a digitally-signed statement that binds the value of the public key to the identity of a particular person, service or device that holds private key. Certification authority allows signing and issuing the certificates. The subject of the certificate is the one that receives a certificate from a CA. Certificates contain the following information.
  1.   Public key of the subject.
  2.    Identifier information like; name and email, etc.
  3.  The valid time period of the certificate. When the validity of the certificate is expired, then the new certificate must be requested.
  4.   Identifier information of the issuer.
  5.   The digital signature of the issuer. In this process data is transformed (some secret information of the sender) into a tag called, Signature.
  6.  Server created self signed certificates follow X.509 standard and X.509 v1 fields.

Asymmetric Keys

 

An Asymmetric Key is a combination of public and private key. Each key used to decrypt data encrypted by the owner. Asymmetric encryption provides a higher level of security comparable to symmetric keys and are relatively-intensive. It is used to encrypt a symmetric key for storage purpose in the database.

Symmetric Keys


A symmetric key is used for both encryption and decryption of the data information. By using symmetric key the process of encryption and decryption has been made faster and suitable for sensitive data stored in the database.

Transparent Data Encryption


TDE is used to encrypt entire database using symmetric key called Database Encryption Key. The database key is protected by other certificates or keys which are protected by the master or by an asymmetric key, stored in an EKM module. TDE uses symmetric key for encryption.

Conclusion:

In the above paragraph I have explained all the encryption techniques and their types in SQL Server along with a brief description about their process or uses. The encryption process is more important considering a part of the SQL Server database that guarantees data security by its complex techniques. For more details about the encryption type, kindly wait for the next blog update.

Wednesday, 4 April 2018

7 Steps to Repair Database from Corruption

SQL Server Database is an advance relational database management system, which is widely used by business professionals. But one of the serious issue one faces is SQL Server Database Corruption.

It is estimated that 99% of Database Corruption in SQL Server is caused due to the problem in IO subsystem level. It means the root cause of Database Corruption in SQL Server is an issue in Disk Subsystem, Disk Controllers, Disk Drivers and possibly Communication Channel.

The corruption is the serious issue, faced by many DBAs and users in an organization and tackling it is the biggest challenge.So, taking regular backup of SQL Server Database is the key to prevent data from Corruption. But, sometimes .bak file also tends to be corrupted due to some hardware or software failure.

Possible Database Corruption Issues

There are various reasons for getting SQL Server Database getting corrupted.

The above issues show various reasons for Database Corruption. For that case, SysTools SQL Recovery Software is one of the key available tool to manage all corruption related problems in SQL Server. The tool promises to give quick solution to various critical corruption problems.It's a handy solution which provide us ease in performing simple recovery steps.

Steps to Recover Corrupt Database in SQL Server

  1. Download SysTools Software Recovery Tool and run it on your machine.
  2. Click ‘Open’ to browse your corrupted MDF File location and open it from its location.
  3. Software gives you two options, one is of ‘Scan Mode’ and other is of selecting version of SQL Server. Choose ‘Quick Scan’ for normal level corruption or ‘Advance Scan’ for high level corruption. The next option is to select the version of SQL Server. Whether choose Auto Detect or select the version of MDF File manually.
  4. The tool will display the scanning report after performing Quick Scan mode.
  5. If the level of corruption is high or the expected results does not found to be “Quick Scan”, the software will notify you to perform Advance Mode scanning.
  6. After scanning,the software will preview the data of recovered database objects.
  7. Software gives you two different options to save recovered data. After clicking on ‘Export’, save the repaired data as of your choice, either as SQL Server Database or as .sql script.

Conclusion

Database Corruption in SQL Server Database is the major problem DBAs or any users face. There are various manual repair methods to recover the corrupted database. By running database console commands like DBCC CHECKDB or REPAIR_ALLOW_DATA_LOSS, one can fix minor level corruption. But if the MDF file is severely corrupted, it is possible that the manual solution fails in recovering data. It is advised to try SysTools SQL Recovery Software for repairing highly corrupted SQL Database files.