Hi to all,
I created following table

-------------------------------------------------------------------

create table interiors(id integer, name varchar(20), type varchar(20) default 'baby cot', price integer)

--------------------------------------------------------------------

but, when i doesn't inserted any value of 'type', by the definition of table, it should take default value. when i fetch all rows by 'select' query, it doesn't show default value.

can anyone tell me that what is the problem?

Thanks & regards,
Pooja.

What version of SQL Server are you using? I tried this code on SQL2000, 2005 and 2008 and it worked in every case.

create table interiors
(
id integer, 
name varchar(20), 
type varchar(20) default 'baby cot', 
price integer
)
go

insert into interiors
(id, name, price)
values
(1, 'Using Default', 100)
go

insert into interiors
(id, name, type, price)
values
(2, 'Not Using Default', 'Not Default', 200)
go

insert into interiors
(id, name, price)
values
(3, 'Using Default Again', 300)
go

select * from interiors
go

All three cases gave the following result:

id  name                   type          price
1   Using Default          baby cot      100
2   Not Using Default      Not Default   200
3   Using Default Again    baby cot      300
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.