jagguy
asked on
sql null
I have a smallint data type in sql ex 2008.
I want a default value of 0 so what do I do?
I want a default value of 0 so what do I do?
You could set a default value on the column in the table design, is that what you mean?
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...
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...
use alter table to create a constraint
alter table emp2
add constraint MyColumnDefX default (1) for MyColumn
ASKER
IN sql management studio what can i do because i am using this an dprefer to use this.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
in management studio
select new query
and run the code!
select new query
and run the code!