Coding⏱️ 2 min read📅 2026-06-03

How to Fix: Remove Trailing Spaces and Update in Columns in SQL Server

Remove trailing spaces from SQL Server column and update in columns.

Quick Answer: Use the `TRIM()` function to remove trailing spaces, e.g. `UPDATE table_name SET Company_Name = TRIM(Company_Name);`

Trailing spaces in a column can be frustrating and make data entry or analysis more difficult. In this article, we will explore why trailing spaces occur in SQL Server columns and provide two effective solutions to remove them.

🔍 Why This Happens

  • Trailing spaces can be introduced during data entry or when importing data from other systems.

✅ Best Solutions to Fix It

Method 1: Using TRIM Function

  1. Step 1: Use the TRIM function to remove trailing spaces from the column.

Method 2: Using SUBSTRING or REPLACE Function

  1. Step 1: Use the SUBSTRING or REPLACE function to remove trailing spaces from the column.

🎯 Final Words

By implementing one of these solutions, you can effectively remove trailing spaces from your SQL Server columns and improve data integrity.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions