Вопрос

Let's say I have nvarchar(300) column.

I append the text as follows:

update tablename set fieldname = fieldname + 'appended string'

How can I tell SQL Server to automatically trim the text from beginning to ensure it never exceeds the maximum column length?

Это было полезно?

Решение

You could use the RIGHT function for that:

update tablename set fieldname = RIGHT(fieldname + N'appended string', 300)
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top