How to Create DEFAULT Constraints on column in SQL SERVER 2008

By
The DEFAULT  CONSTRAINT  is used for default value, when the insert statement does not provide any specific value. DEFAULT CONSTRAINT  are special case of column default.It is also used when we use any scripting code for the SQL Database.
There are some steps to Know about DEFAULT CONSTRAINT  Which are given below:-
Step1:- Create table and apply the DEFAULT constraint on column.
create table student1(id int, name char(20),city char(30)constraint def default 'delhi')

Step2:- Create DEFAULT constraint on existing column.
alter table student1 add constraint def1 default 'india' for city

Step3:- Insert the data in student1 table.
insert into student1 values(101,'rajesh','india')

Step4:- Drop the constraint from the table.
alter table student1 drop constraint def

SEE IT:-

For More:-
  1. Microsoft Sql Server
  2. Create Table Without Command
  3. Check constraints
  4.  File Handling Real Application
  5. Add Identity Column
  6. Copy Data from one table to another table
  7. Stored Procedure
I hope this is helpful for you.
To Get the Latest  Free Updates Subscribe
Click below to download whole command file.
     DOWNLOAD

0 comments:

Post a Comment

Powered by Blogger.