About
Pricing
Community
Teams
Start Free Trial
Log in
jagguy
asked on
3/9/2011
sql null
I have a smallint data type in sql ex 2008.
I want a default value of 0 so what do I do?
Microsoft SQL Server 2008
Microsoft SQL Server 2005
6
1
Last Comment
Lowfatspread
8/22/2022 - Mon
Paul Jackson
3/9/2011
You could set a default value on the column in the table design, is that what you mean?
Lowfatspread
3/9/2011
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...
Ephraim Wangoya
3/9/2011
use alter table to create a constraint
alter table emp2
add constraint MyColumnDefX default (1) for MyColumn
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
jagguy
3/9/2011
ASKER
IN sql management studio what can i do because i am using this an dprefer to use this.
ASKER CERTIFIED SOLUTION
Paul Jackson
3/9/2011
THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Lowfatspread
3/9/2011
in management studio
select new query
and run the code!