Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
melcraig
Starting Member
39 Posts |
Posted - 2006-04-13 : 13:30:25
|
| Hi Everyone,Somehow when they imported data into a column that did not allow nulls it accepted them anyway.I have two columns LastName, FirstnameIf the FirstName is nullI want to copy the LastName into the FirstName column.Any easy suggestions, Please?This is the greatest site!Thanks, Mel |
|
|
TimS
Posting Yak Master
198 Posts |
Posted - 2006-04-13 : 13:37:11
|
| UPDATE t SET t.Firstname = t.LastName-- SELECT t.Firstname, t.LastNameFROM tablename tWHERE t.Firstname IS NULLYou should run the select part to confirm it right then run the updateTim S |
 |
|
|
druer
Constraint Violating Yak Guru
314 Posts |
Posted - 2006-04-13 : 14:34:19
|
| Do you actually get the value "NULL" when you select the data, or is it just blank? Could there actually be a "blank" value '' which is why the constraint was overlooked?Would you consider setting the first name to "NOT_POPULATED_ON_LOAD" or something instead of copying the last name to that field, to make it clear whenever the value is looked at that you don't really have the correct value for that field and that the record should then be updated?Just some thoughts,Dalton |
 |
|
|
melcraig
Starting Member
39 Posts |
Posted - 2006-04-13 : 15:00:37
|
| Thanks for the help.Someday maybe I will be able to help others.And yea, the column is actually a null. This is a legacy db, that has been around forever, so who know how the data got in there in the first place. I should not have to do this again! Hopefully!Thanks for helping meMel |
 |
|
|
|
|
|