• elbedata (9/4/2009)


    You mean, when changing the datatype from fixed length to varying length?

    I'd hesitate to describe an unasked for removal of trailing spaces "smart". There are builtin functions to remove them on demand, but no builtin functions to easily restore them after they have been removed...

    I get your point (and it is of course valid), but if you really need the trailing spaces, why change the datatype?

    In this case, I don't need them and I'll free up the space by explicitly trimming the data after the change.

    But SQL Server doesn't know. It might also be that I'll trim some of the data but not all. Or that the trailing spaces have to be preserved on existing data but new data coming in will be trimmed. Or (...)

    That's what I meant with my previous post: I can trim easily if I want to, but I can't easily "untrim" if SQL Server would do that automatically. And since SQL Server doesn't know what I want, it should stay on the "safe" path and not make irreversible changes I don't ask for.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/