Reputation: 4601
In a SQL statement, how do you limit the returned value of a text field char length to a certain size?
Tried so far-
select len(mytextfield,30) from table
Upvotes: 1
Views: 4010
Reputation: 1051
select left(mytextfield,30)
I am not positive, but I think the substring function does not work against the TEXT datatype.
Upvotes: 1
Reputation: 7299
You want the SUBSTRING function.
SELECT SUBSTRING(mytextfield, 1, 30) FROM Table
(This is assuming SQL Sever / T-SQL; you didn't specify a database engine.)
Upvotes: 4