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

How to insert blank in field having int data type. Null also not allowed.

Posted on 2014-03-10
3
1,609 Views
Last Modified: 2014-03-10
I am having table testdata(i int)

insert into testdata values(1) ok
insert into testdata values(dbnull.value) ok

i want to insert blank only, neither null not '' converting datatype to varchar
and then converting to int
0
Comment
Question by:searchsanjaysharma
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 39917490
sorry, but for numerical data types (like int), you cannot have any "blank" data except NULL.
so, if you ask with the restriction of "not null", the answer is :
this cannot be done
0
 
LVL 25

Assisted Solution

by:SStory
SStory earned 250 total points
ID: 39917517
Guy is correct. The only other option would be a magic number. Example: If all data must be positive you could insert a -13 to mean nothing and your code would need to interpret it and ignore/display as desired.  However, I'd prefer NULL.
0
 

Author Closing Comment

by:searchsanjaysharma
ID: 39917547
tx, so that means i can use the option of cast. this also defined the blank() function doesnt work
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

809 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