Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

sql null

Posted on 2011-03-09
6
190 Views
Last Modified: 2012-05-11
I have a smallint data type in sql ex 2008.
I want a default value of 0 so what do I do?
0
Comment
Question by:jagguy
6 Comments
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 35089453
You could set a default value on the column in the table design, is that what you mean?
0
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 35089460
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
 
LVL 32

Expert Comment

by:ewangoya
ID: 35089467

use alter table to create a constraint

alter table emp2
add constraint MyColumnDefX default (1) for MyColumn
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

Author Comment

by:jagguy
ID: 35089730
IN sql management studio what can i do because i am using this an dprefer to use this.
0
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 500 total points
ID: 35089736
Go to the table design view, select column and set default value to 0
0
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 35089895
in management studio

select new query

and run the code!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question