Skip to content
Advertisement

Inserting multiple rows of data into a single column

Absolute SQL beginner here:

I have a table ‘students’ with the columns ‘id'(primary key), ‘name’ and ‘mark’.

I am now trying to add the marks for a number of students. Just using multiple UPDATE statements like

seems rather dull and labor intensive. What would be the most simple and elegant way to execute such an operation using MS SQL?

Advertisement

Answer

First of all I would like to say that your code is perfectly fine as is. That said, in my opinion this might be a bit prettier:

But again there is no need to make it more complicated than you did it. SQL is more about writing fast and accurate code than making it pretty.

Also, Welcome to Stack Overflow!

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement