Solved

sql null

Posted on 2011-03-09
6
191 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
[X]
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
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:Ephraim Wangoya
ID: 35089467

use alter table to create a constraint

alter table emp2
add constraint MyColumnDefX default (1) for MyColumn
0
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SSAS Hierarchy with columns with folder names 10 29
MS SQL Update query with connected table data 3 63
PROPERCASE SCRIPT IN SQL 3 23
Change this SQL to get all nodes 3 40
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

733 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