cancel
Showing results for 
Search instead for 
Did you mean: 

Change column datatype from varchar to nvarchar

Former Member
0 Kudos

Hi,

I'm trying to change datatype of a column using

"ALTER TABLE <table-name> ALTER(<column-name> NVARCHR(100))"

This is giving me an error "SAP DBTech JDBC: [7]: feature not supported: cannot modify column type from varchar to nvarchar"

Any idea, how to achieve this ALTER?

Regards,

Shubham

Accepted Solutions (1)

Accepted Solutions (1)

michael_eaton3
Active Contributor
0 Kudos

Typically, when an ALTER is not supported, you would add a new column of the desired datatype, update the new column with the old column's content, drop the old column, and rename the new column to be the same as the original column.

Michael

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Shubham,

According below SQL Guide, conversion from VARCHAR to NVARCHAR should not be an issue.

https://help.sap.com/saphelp_hanaplatform/helpdata/en/20/a1569875191014b507cf392724b7eb/content

.htm?frameset=/en/20/9ddefe75191014ac249bf78ba2a1e9/frameset.htm&current_toc=/en/2e/1ef8b4f455473995...

See if you are reducing column length. If not, while changing from VARCHAR to NVARCHAR, try to give column length as more than double of VARCHAR length.

Lets say if your existing column has VARCHAR(50), then for NVARCHAR give more than 100.

Regards,

Venkat N.

Former Member
0 Kudos

There's a restriction on row size, can't increase it. Actually I wanted to convert it to nvarchar and decrease the size as well. (From varchar(x) -> nvarchar(x/4))

michael_eaton3
Active Contributor
0 Kudos

If you have a key on this table - insert the column data (and its key!) into a temporary table, drop the column, add the column back with the new datatype, then update it with the contents of the temporary table.

Michael