Information is converted to digitalized format and then flows through the network medium. Security mechanisms are mostly used to protect information from unauthorized intruders on the network. Secure communication between the medium as well as between the communicating entities is an essential part. There exist many types of attacks in which the SQL Injection is considered for the proposed work. This paper proposed a novel method for the detection and proper replacement to the affected queries. SQL Injection is one of the major attacks which will leaks the valuable information to the intruders. SQL Injection attacks target databases that are accessible through frontend structure of the website, and made flaws in the input validation logic of its components. Therefore, a strong method is needed to overcome the dispute. This paper proposed an efficient method for detecting the SQL injection by manipulating input attributes of the SQL query and measuring the distance of query strings.  It satisfies the both query analysis for both the static and dynamic manipulation of user queries.