In a view, i have a column comments which may contain large string. I just want to select first 60 characters and append the '...' at the end of the selected string.
For selecting first 60 characters i have used following query:
select LEFT(comments, 60) as comments from myview
Now i want its processing as below:
Thanks
To conditionally check the length of the string, use CASE
.
SELECT CASE WHEN LEN(comments) <= 60 THEN comments ELSE LEFT(comments, 60) + '...' END As Comments FROM myView
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With