Skip to content

Commit 1c273f8

Browse files
committed
[MSSQL] Fix string length when using nchar, nvarchar, ntext
1 parent 70d2ae2 commit 1c273f8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/providers/mssql/qgsmssqlprovider.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -418,11 +418,16 @@ void QgsMssqlProvider::loadFields()
418418
}
419419
if ( sqlType == QVariant::String )
420420
{
421+
int length = query.value( 7 ).toInt();
422+
if ( sqlTypeName.startsWith( "n" ) )
423+
{
424+
length = length / 2;
425+
}
421426
mAttributeFields.append(
422427
QgsField(
423428
query.value( 3 ).toString(), sqlType,
424429
sqlTypeName,
425-
query.value( 7 ).toInt() ) );
430+
length ) );
426431
}
427432
else if ( sqlType == QVariant::Double )
428433
{

0 commit comments

Comments
 (0)