mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-03 00:02:25 -05:00
Retrieve the primary key column when opening MS SQL tables and no identity column has been specified
This commit is contained in:
parent
8f22e21ddd
commit
067d7dd467
@ -337,6 +337,19 @@ void QgsMssqlProvider::loadFields()
|
||||
}
|
||||
}
|
||||
}
|
||||
// get primary key
|
||||
if ( mFidColName.isEmpty() )
|
||||
{
|
||||
mQuery.clear();
|
||||
mQuery.exec( QString( "exec sp_pkeys N'%1', NULL, NULL" ).arg( mTableName ) );
|
||||
if ( mQuery.isActive() )
|
||||
{
|
||||
if ( mQuery.next() )
|
||||
{
|
||||
mFidColName = mQuery.value( 3 ).toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user