Skip to main content

Posts

Delete duplicate records from table in single statement (SQL Server)

Deleting duplicate records is very common requirement therefore multiple options are available to delete duplicate records. However this article provides the solution to delete the duplicate records using single statement. Delete from <TABLE_NAME> where <ID> not in ( select max(<ID>) from TABLE_NAME> group by <DUPLICATE_COLUMN>) For example: Employee table EmpId EmpFullName EmpSalary EmpTitle 1 Sumit Bajaj 5000 Dev 2 Amit 10000 SDev 3 Sumit Bajaj 5000 Dev 4 Priyanka 50000 Mgr 5 Umesh 10000 SDev 6 Umesh 10000 SDev 7 Amit 10000 SDev 8 Geetika 5000 Dev where few records are duplicate and need to be removed. For this table, delete query would be  Delete from Employee where EmpId not in (select max(EmpId) from Employee group...

Oracle SQL Developer Installation

After spending enough time on installing Oracle SQL Developer and respective issues, I thought of writing few easy steps to install it. Hope it would help and save your time. Steps to install Oracle SQL Developer(for windows): Download SQL Developer from Oracle site. Download Download JDK if it is not installed on your machine. Download Install JDK and then unzip SQL Developer Click on sqldeveloper.exe, it will ask for java.exe path Open the path where JDK is installed. It would be something like "C:\Program Files\Java\jdk1.7.0_40\jre\bin" depeneding upon which version you install. If it is giving any exception, remove the entry [SetJavaHome] from sqldeveolper.conf file from "..\sqldeveloper\sqldeveloper\bin\sqldeveloper.conf" and give the correct path of java.exe file. Please provide your feedback if you like the post.

Excess of technology ruins

M ost of us are using so many apps on mobile and spending plenty of time using those apps. Well, even I am not exception but excess of technology sometime ruins. I would like to narrate one incident where I used Google Maps and screamed after using it. I visited Dehradun, Uttrakhund from Gurgaon recently and chose Google Maps to show me the route. It showed me two ways and advised me to go via shortest route which I followed. After reaching half way, I found that road was damaged so badly that I was not able to proceed. After collecting information from villagers nearby, I got to know that this path was always like that. One of the villagers advised me not to go further on that path as for cars its not possible to cross. He advised me to take alternate route which was going through the villages. Thanks to Indian people who are so kind and helpful. Although that road was raw and some patches were there yet it was better then the path Google Maps proposed. By somehow, I could reach ...

Could not load file or assembly 'MySQL.Data' or one of its dependencies. Access is denied.

It is very common error with .net assemblies. When someone included dlls from outside, in the project, this kind of exceptions are generic. Here is the resolution. Open the file location ( MySql.Data.dll in this case ) Right click on dll and check its properties ( it should not be encrypted and should have right access permissions ) Run the project after assigning appropriate permissions. It should work now. Even after this if it does not work. Check in web.config that assembly information is added under <compilation> tag. It is advisable to included new dlls using nuget package reference. It will update its reference automatically. Happy Coding!!!

Google search appliance (GSA) sorting and filtering

Working with Google Search Appliance(GSA), sometimes business has requirement of sorting or filtering the results. Browsing the internet did not provide any helpful pointers for the ways to sort or filter the search results therefore I have written these instructions to use sorting & filtering in easy way with examples . Sorting: Google Search Appliance(GSA) has provided the tags to sort the results in ascending or descending order. Pages should have meta tags which provides information to GSA box for crawling. Using those tags, sorting can be achieved. For example: If web pages has a tag <meta name =" title " content =" Sumit Bajaj::Passionate Technologist " /> GSA URL should include parameter to sort the results &sort=meta:title:a  (for arranging all results in ascending order w.r.t title) &sort=meta:title:d  (for arranging all results in descending order w.r.t title) Similarly it can be sorted for another meta tags. Filteri...

Host Angular App on Heroku

Angular is one of the javascript frameworks which provides new dimensions of writing javascript and on the other hand Heroku is a web hosting platform which allows applications to host. Most importantly, it gives option to host various applications free of cost. Now considering that an angular project is ready and need to be hosted somewhere so could be accessed publicly. There are few steps which will push the project on Heroku platform and enable the angular project to be browsed by outside world. Pre-requisite: 1. You should have a Heroku account, if not create one. 2. Heroku toolbelt is installed on machine. Once installed using command prompt, enter "heroku login" and provide your email and password to log into heroku account. 3. In case you need some domain name, register it in advance. Otherwise you can access the URL which Heroku provides by default. 4. Last and most important point, you should be ready with angular project. Insure that you are not getting a...

Get ASP.NET Web API to return JSON instead of XML

By default, Web API produces XML but if there is need for JSON, given syntax will do it. Open WebApiConfig.cs file in solution and add mentioned line in it as shown in example. public static void Register( HttpConfiguration config)         {             config.Routes.MapHttpRoute(                 name: "DefaultApi" ,                 routeTemplate: "api/{controller}/{id}" ,                 defaults: new { id = RouteParameter .Optional }             );             //To produce JSON format add this line of code      ...