Whenever we do data migration from any old systems to new / upgraded systems, we usually receive data in different formats (text files, cvs, excel etc.) to insert into SQL Server. Sometimes, due to the different formats, the additional white spaces accompany the data. These additional white spaces create problems later in the application. In this article, I will show you how to view the white spaces and a simple solution to remove them from the data, horizontally.
Let me explain this, step by step.
Step 1 :
Copy the data from any format (text files, cvs, excel etc.) to SQL Server editor (new query window). In my case, I will copy the data from text file and paste it into SQL Server editor.
Given below is the image.
Step 2 :
Now, you can see that the data is not in a proper order, obviously because the white spaces have accompanied the data . Let’s view the white spaces in the data using SQL Server editor.
Click on the Edit menu select Advanced and click on View White Space.
As shown in the given below image.
Given below is the image showing white spaces.
Step 3 :
Now, select the data from where you need to remove the white spaces horizontally (Note : If you want to remove white space from one line or from either left side or right side, just select that particular area as shown in the image below).
Step 4 :
Once you select the data to remove horizontal white space, click on the Edit menu, select Advanced and click on Delete Horizontal White Space, as shown in the picture below.
Step 5 :
Now, you can see, in less than seconds the white spaces are removed from your data without any effort.
Let me know how you usually remove the white spaces horizontally from the data.
Leave a Reply