sql update - First time Updating a table -
I was recently allowed to update a table in our database, but this is not something I have previously And I do not try to mess up anything, I tried to search something online which is what I want to do with success.
The name of the table is dbo.Player_Miles and it has only two column data data_ID and miles which are both set (int, null)
currently in this table There are about 300 records and I have a CSV file which I have to use to update this table. There are 500k records in the file so I need to be able to:
enter new record ~ 250k records
Update the records that have new information ~ 200 records < / p>
leave the untouched and record which is the same information (though updating the same things will not harm the database, which I would think) ~ 50 records
Anything other than Leave the record currently in the table Which are not in the update file ~ 50 Records
I am using Ssms 2008, Server 2000.
You can contact this step ...
1) Backup Database
2) Create a temporary SQL table to keep your updated records
Player_Miles_Updates (PlayerId int no null, Miles int null) to create the table 3) Load the record in your floating table
bulk insert Player_Miles_updates 4) Start a transaction
Select PlayerImiles from Player_Miles_updates, select the mile from playerImiles_Updates, where PlayerId does not exist (PlayerIds Select)
6) to update your existing data
set Pleyrmals updates Player Player PlayerId. Miles = pmu. Miles pmiles Player_Miles_Updates from player_Miles at pmu pm.P 7) Select some rows to make sure what you want to do, select Choose from Player_Miles * where in Player_Id (1,45,86 , 14,83) - Use the ID that you saw in the CSV file 8a) if everything went well
commit transaction 8b) If everything does not go well
rollback transaction 9) Delete a temporary table < / P> Drop Table Player_Miles_Upda Tes
Comments
Post a Comment