How to split a sentence and get only left 15 or less (Not greater than 15) characters on one column but it could be a complete word.
Ali, House Number ABC/123, Sattelite Town, Lahore.
Column 01 Column 02 Column 03 Column 04 Ali, House NumberABC/123, Sattelite Town, Lahore.
Need support here.
You can try something like this:
DECLARE @Str VARCHAR(100) = 'Ali, House Number ABC/123, Sattelite Town, Lahore.' SELECT LEFT(LEFT(@Str, 15) , 15 - CHARINDEX(' ', REVERSE(LEFT(@Str, 15))) )
10 People found this is helpful