The naming of your fields suggests that PKey should be your primary key, which cannot be empty in the first place, if you set up the data extension correctly.
So therefore you need to either
- add this functionality to the query that initially fills your data extension, or
- set it as a default value in the data extension setup.
For the SQL solution you could use the NEWID-function:
SELECT
NEWID() as PKey,
FieldA,
FieldB
FROM
SourceDE
The data extension setup-version would be adding GUID()
as default value for that field.
However, both solutions lead to IDs that aren't numerical, but rather IDs in GUID format (alphanumeric with dashes as separators).
Related documentation: