Trim spaces in a T-SQL INSERT

I'm running an insert T-SQL statement to inter one record from one table to another. There is an nvarchar(100) field in the insert. Even if a wrap the nvarchar field in RTRIM or SUBSTRING, the insert result is that the target table field includes the padding of spaces beyond the value of the field. For example, if the value of the source field is "Answer", the value in the target field after the insert is "Answer                                                                                            ", i.e., the value + spaces. Any thoughts?
paulmcneilAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BeartlaoiCommented:
It sounds like the target column is defined as a fixed width string rather than variable.
Verify the type of the target column is an nVARchar or other variable string.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PortletPaulfreelancerCommented:
& This should tell you what that field's data type is. No points pl.
SELECT
      c.name
    , t.name as type_name
    , c.max_length
    , c.collation_name
    , c.column_id
    , c.is_nullable
FROM sys.columns AS c
INNER JOIN sys.types AS t ON c.system_type_id = t.system_type_id

WHERE object_id = OBJECT_ID('dbo.YourTableName') --<< change to suit

AND c.name = 'TheFieldName' --<< change to suit

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Applications

From novice to tech pro — start learning today.