Click here to Skip to main content
15,906,628 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In database design structure as follows


Billno Varchar(10)
Course Varchar(10)
Special Discount Varchar(10)



using sql query i want to insert the Special Discount value is 0, if the Special Discount value is not there in the database


for that how can i do using sql query.

Rgds,
Narasiman P.
Posted

Don't use Varchar(N) if the column suppose to take integer value.

SQL
ALTER TABLE TableName ADD CONSTRAINT ConstraintAnyName DEFAULT '0' FOR Special Discount;
 
Share this answer
 
v2
SQL
ALTER TABLE TableName
 ALTER COLUMN ColumnName SET DEFAULT 0

Refer this for more info...
SQL DEFAULT Constraint[^]
 
Share this answer
 
SQL
Update TABLENAME set [Special Discount]=0 where [Special Discount] is null
 
Share this answer
 
v2

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