dimanche 26 avril 2015

Add incremental values in a single insert statement

The query below is not my actual query but a minimized version of it, as I cannot post the original one. However this explains what I want to do exactly:

Insert into TableA (BirthdateA, NameA)
Select BirthdateB,  (case when NameB is not null then NameB else "Desired Value" End) 
From TableB

"Desired Value" should be a dummy name in addition to an incremental value, for example "Dummy Name 1", "Dummy Name 2" So the final result would look like

TableB.Name     TableA.Name
John Smith       John Smith
Null             Dummy Name 1
Adam James       Adam James
John K.          John K.
Null             Dummy Name 2

Is that possible ?

Aucun commentaire:

Enregistrer un commentaire