sql null

I have a smallint data type in sql ex 2008.
I want a default value of 0 so what do I do?
jagguyAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Paul JacksonConnect With a Mentor Software EngineerCommented:
Go to the table design view, select column and set default value to 0
0
 
Paul JacksonSoftware EngineerCommented:
You could set a default value on the column in the table design, is that what you mean?
0
 
LowfatspreadCommented:
in the column definition for the table   have the phrase  DEFAULT 0

create table x  (col1 smallint default 0  , ....)

or
alter table x alter column x smallint default 0

Insert into x (col2,....)     -- but don't name the col1
  values (1,2,...)     -column col1 will get the default

or Insert into x (col1,col2,...)
 values (DEFAULT,1,2,...)   -- using the KEYWORD DEFAULT


is that what you where asking for ?  otherwise please be specific and state what you need to know understand...
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
Ephraim WangoyaCommented:

use alter table to create a constraint

alter table emp2
add constraint MyColumnDefX default (1) for MyColumn
0
 
jagguyAuthor Commented:
IN sql management studio what can i do because i am using this an dprefer to use this.
0
 
LowfatspreadCommented:
in management studio

select new query

and run the code!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.