mardi 16 juin 2015

SQL Server convert varchar column to computed column without losing existing column data

Is it possible to convert a normal column to a computed column (persisted) without losing the existing data? The older data in the column doesn't quite follow the pattern I want to implement, but would work fine with the newer data.

The only way I could think of doing it is rename the column, create a new column, write a function that would first populate from old column, if null use formula.

I've tried setting a default binding, but I need the value of another column for my function and that doesn't seem to work.

I'm also trying to avoid a trigger because I'm using a generic "insert output inserted" statement and triggers cause a DML statement error.

Hope that makes sense. Thank you.

Aucun commentaire:

Enregistrer un commentaire