VARCHAR to NVARCHAR

  • I'm inserting records into a table. One value is a constant: 'XYZ'. The targtecolumn is defined as NVARCHAR(100) and I get a conversion error when trying to insert VARCHAR into NVARCHAR.

    I'm thinking of using CAST or CONVERT, but is there not an easier way? I am amazed that a conversion like this is not automatically taken care off...

    Greetz,
    Hans Brouwer

  • That is usually seemless. What collation is set on that database?

    BTW, if you're data in the database is nvarchar and you use varchar in your parameters or what have you, you will be getting (normally) an implicit conversion that will preclude indexes being used.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Right....

    There is indeed a different collation on some columns. I'll have to delve into that.

    Tnx.

    Greetz,
    Hans Brouwer

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply