SEL开发者_如何学GoECT First 20 Chars of(ColName) from DB
Is this possible?
SELECT left(ColName,20) AS First20 /*(Or 30 if we are looking at the title)*/
FROM YourTable
SUBSTRING(ColName, 1, 30)
SELECT CONVERT(VARCHAR(30), ColName) from DB
Assuming that colname is VARCHAR, all the above will pad shorter strings to 20 characters.
If this is not what you want, then:
SELECT RTRIM(LEFT(colname, 20)) FROM DB
You can simply use one of the built in string functions. There are many variants so its best to see which one suits your situation best.
Enjoy!
精彩评论