How to delete leading empty space in a SQL Database Table using MS SQL Server Management Studio

前端 未结 1 596
一向
一向 2020-12-31 03:01

I imported an Excel sheet with countries into a database table.

Unfortunately all rows have some leading empty space.

So, how can I delete these empty spaces

相关标签:
1条回答
  • 2020-12-31 03:32

    This will remove leading and trailing spaces

    Update tablename set fieldName = ltrim(rtrim(fieldName));
    

    some versions of SQL Support

    Update tablename set fieldName = trim(fieldName);
    

    If you just want to remove leading

    update tablename set fieldName = LTRIM(fieldName);
    
    0 讨论(0)
提交回复
热议问题