The OrderKey needs to be updated by each TableName. So if TableA was repeated 4 times and TableB was repeated 3 times it would look like:
TableName (nvarchar) OrderKey (int)
TableA 10
TableA 20
TableA 30
TableA 40
TableB 10
TableB 20
TableB 30
This is the code that I have:
The error I get is: String or Binary data would be truncated. The error points to: WHERE TableNameLabels <> ''
Thanks for the help.
TableName (nvarchar) OrderKey (int)
TableA 10
TableA 20
TableA 30
TableA 40
TableB 10
TableB 20
TableB 30
This is the code that I have:
Code:
WITH FieldOrderKey (TableName, TableNumber) AS
(
SELECT TableNameLabels, ROW_NUMBER() OVER(PARTITION BY TableNameLabels ORDER BY TableNameLabels) AS [TableNumber]
FROM tblzCdCustomFieldLabels
WHERE TableNameLabels <> ''
)
UPDATE tblzcdCustomFieldLabels
SET tblzcdCustomFieldLabels.OrderKey = TableNumber * 10
FROM tblzcdCustomFieldLabels
INNER JOIN FieldOrderKey ON tblzcdCustomFieldLabels.TableNameLabels = FieldOrderKey.TableName
The error I get is: String or Binary data would be truncated. The error points to: WHERE TableNameLabels <> ''
Thanks for the help.