Possible commonly suggested approaches are:
- All the story points go the sprint where the story got completely finished.
- The story gets splitted, an estimation of the remaining work is made, and the points are assigned partially to two sprints.
- The points of the unfinished story are not counted at all.
- The story is re-estimated considering only the work that is still left, which is likely to be a smaller number. Only the new estimation is taken into account.
There is no correct answer. It all depends on how the team interprets and uses the story points. It is important though to choose one approach and stick to it.
Approach 1 is the one that I find more appropriate, although it tends to cause a bigger variation in the amount of store points per sprint. Approach 2 tends to be problematic, because all stories should have business value individually, and splitting stories is not always straightforward. The reason I don't like approaches 3 and 4 is because I think story points should be used by the team to estimate their velocity. When you decide to trash the points of partially finished stories, you end up not being able to predict the velocity very well.
For example, let's say that the team has three stories in the backlog, with estimated points A) 3, B) 7 and C) 5. In the first sprint the team managed to finish A, and almost finished B. So they take the rest of B and C to the second sprint. At the end of the second sprint all the stories are finished. If the team chooses approach 3, in this case they finished 3 story points in the first sprint, and 5 in the second sprint. This would mean that the team velocity is 4 points per sprint, when their actual speed, considering the two sprints, was almost twice that value. Approach 4 would have slightly different results, but the consequences are basically the same.
These differences are not so big in real cases, because you end up having more than one story per sprint, and if your stories are small enough, the remaining story points are negligible in comparison to the team velocity.
So, the best option is to discuss with your team, decide how you want to use the outcome of the story points, and choose the approach which fits best for you.