How can I select the first 100 characters in SQL Server?

前端 未结 5 926
灰色年华
灰色年华 2021-01-03 18:25

I want to truncate a column to a max of 100 characters. How do you do this in SQL Server?

5条回答
  •  孤独总比滥情好
    2021-01-03 19:12

    Try this:

     SELECT LEFT (your_column, 100) FROM your_table 
    

    Edit:

    you can also try something like this:

      SELECT LEFT (your_column, LEN(your_column)-5) FROM your_table 
    

    for say if you want to trim the last 5 characters from a record.

提交回复
热议问题