Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add column value in SQL Server 2008 r2?

I created a table called Dummy with 4 columns: Date, Year, Student_Names, Subject.

After a few days I need to add one more column name called Marks.

I know how to add column Marks by using the SQL query, I am using the query below:

Alter Table Dummy 
add Mark varchar(30)

After I add the column, all values are NULL, I need some value in the place of NULL.

How do I add those values? Values are mentioned in an Excel file.

like image 861
Jojin.Jose Avatar asked Sep 21 '25 10:09

Jojin.Jose


2 Answers

Try,

Alter Table Dummy ADD Mark varchar(30) DEFAULT ''

or

UPDATE Dummy
SET [MArk] = 'new value'
like image 115
Ambrose Avatar answered Sep 23 '25 01:09

Ambrose


your code is update Dummy set Marks = 10 where Student_Names = name you want to add marks to

like this you can add marks to all the students

good luck

like image 24
Learner Avatar answered Sep 23 '25 00:09

Learner