开发者

Using LEFT on a TEXT-field in SQL Server

开发者 https://www.devze.com 2022-12-08 03:33 出处:网络
In a table, I 开发者_如何学Chave a text-field. I need to be able to select only the first 200 chars of the field - but LEFT does not work with TEXT-fields.

In a table, I 开发者_如何学Chave a text-field. I need to be able to select only the first 200 chars of the field - but LEFT does not work with TEXT-fields.

What to do?


instead of left . try with SUBSTRING

e.g : select SUBSTRING(TEXT,1,200) from dbo.tblText


You cannot apply string manipulation functions on TEXT fields - you should stop using TEXT anyway, since it will be removed from SQL Server soon!

What you can do is convert your TEXT column to VARCHAR(MAX) And then use the string gfunction:

SELECT LEFT(CAST(YourTextCol AS VARCHAR(MAX), 200) .....
0

精彩评论

暂无评论...
验证码 换一张
取 消