0

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.

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by BitBlt
0

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
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.