Solved

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

Posted on 2014-03-10
3
1,631 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Insert from Stored Procedure where some field/s > 0 7 47
INSERT DATE FROM STRING COLUMN 18 63
SQL Query with Sum and Detail rows 2 62
Help  needed 3 44
by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

726 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