dimanche 17 juillet 2016

Create column with Cast in SQL

i need to create some columns that has some autogenerated data in it using values from other columns in the table

I know that if i do something like this it'll work

ALTER TABLE Directions ADD RevisedLat INT
UPDATE Directions SET RevisedLat = CAST(Latitude*3200/90 AS INT)

however, i want to do the cast in the add query and this doesn't work

ALTER TABLE Directions ADD RevisedLat CAST(Latitude*3200/90 AS INT)

what is the best way to get this working? just do the add and update?

Aucun commentaire:

Enregistrer un commentaire