convert data type

  • How i can convert varchar(20) to Nvarchar(20) and Nvarchar(16) to nvarchar(20).

  • where do you want to convert?

  • I have one destination column with Nvarchar(20) and i want to load data from two columns and their data types are varchar(20) and nvarchar(16).so that's why i want to change the data type of two sources into nvarchar(20).

  • Explicitly, before loading the data into the the destination column, u can use CAST/CONVERT to convert them.

    But, AFAIK, SQL Server will implicitly convert the source columns to NVARCHAR(20) before inserting..

  • I want to convert column_A varchar(20) to column_c Nvarchar(20) and Column_B Nvarchar(16) to column_c nvarchar(20).

    is this right?

    for source column_A having datatype varchar(20)

    cast(ColumnA as Nvarchar(20))

    for source column_B having datatype Nvarchar(16)

    CAST(COLUMN_B AS NVARCHAR(20))

  • weston_086 (3/22/2012)


    I want to convert column_A varchar(20) to column_c Nvarchar(20) and Column_B Nvarchar(16) to column_c nvarchar(20).

    is this right?

    for source column_A having datatype varchar(20)

    cast(ColumnA as Nvarchar(20))

    for source column_B having datatype Nvarchar(16)

    CAST(COLUMN_B AS NVARCHAR(20))

    yes, you are absolutely correct.

Viewing 6 posts - 1 through 5 (of 5 total)

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