Click here to Skip to main content
15,880,608 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
dear all how to update record to database.
i have database in which i have large no. of row
i want to add column and i want to update all empty rows record for some condition how to add it...
no. of row is 1800.

thank in advance
Posted

Try the following SQL to add a new column with a default value:
SQL
ALTER TABLE TestTable
ADD NewCol INT NOT NULL DEFAULT(0)
GO

After this, if needed, you can fire an UPDATE query for the table with your specific condition, updating this new column only, like:
SQL
UPDATE TestTable
SET NewCol = Some_Value
WHERE ID=2 
--some condition
 
Share this answer
 
Comments
P.Salini 5-May-12 5:00am    
my 5!
Sandeep Mewara 5-May-12 5:14am    
Thanks Salini.
Maciej Los 5-May-12 5:01am    
Good answer. My 5!
I was late.... ;)
Sandeep Mewara 5-May-12 5:14am    
Thanks losmac.
VJ Reddy 5-May-12 23:19pm    
Good answer. +5
You can use T-SQL commands:

ALTER TABLE[^]
UPDATE[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900