473,505 Members | 16,800 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sql datatype help

hello,
i m having a problem with the sql database.it does not accept 0(zero)as
the first number in the integer field.whenever i insert 01 it takes it
as 1.similarly for 02 and so on till 09.i want 01. can anyone suggest
how to get.i m doing this on sql server.does sql server support?is this
the problem of sql server?

Sep 13 '05 #1
4 1334
it impplicit cast the value to an integer. An integer with a trailing 0
isnŽa integer, because this is a string. So you should store that as a
char / varchar type to presume that information (same here in germany
after the redesign of the zip code which afterwards contained trailing
zeros)

HTH, jens Suessmeyer.

---
http://www.sqlserver2005.de
---

Sep 13 '05 #2
1 is an integer, '01' is a string. If you want to pad your integers
with leading zeroes, it would be best to do it on the client side, as
that's usually the best place for presentation and formatting. If you
really need to do it when you retrieve the values from the database
then this is one possible way:

select
case when IntColumn between 0 and 9 then '0' + cast(IntColumn as
char(1)) else cast(IntColumn as varchar(10)) end
from dbo.MyTable

Simon

Sep 13 '05 #3
thanks for ur suggestion.

Jens wrote:
it impplicit cast the value to an integer. An integer with a trailing 0
isnŽa integer, because this is a string. So you should store that as a
char / varchar type to presume that information (same here in germany
after the redesign of the zip code which afterwards contained trailing
zeros)

HTH, jens Suessmeyer.

---
http://www.sqlserver2005.de
---


Sep 13 '05 #4
hi Jens,
thanks for ur suggestion.

Jens wrote:
it impplicit cast the value to an integer. An integer with a trailing 0
isnŽa integer, because this is a string. So you should store that as a
char / varchar type to presume that information (same here in germany
after the redesign of the zip code which afterwards contained trailing
zeros)

HTH, jens Suessmeyer.

---
http://www.sqlserver2005.de
---


Sep 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
11864
by: Steve | last post by:
Hi; I have a table with a TEXT datatype. Its a comment field. Right now the users who put in singlequotes are killing the web front end. The programmer responsible is fixing this issue but...
4
3884
by: J.C. Flores | last post by:
Hello all, First of all, I must state that I'm new to SQL Server, but have been a long-time software guy for quite some time. Please excuse the potential simplicity of the solution to my...
1
843
by: Hechmi | last post by:
I am trying to retrieve the users of the company using active directory. When i execute the code below , it gives the following error "The Active Directory datatype cannot be converted to/from...
8
1933
by: Eternally | last post by:
Hi folks, I've got a program which has a function which uses templates to accept parameters of any type. Works well, but there's one certain datatype which I want to special case and do an...
1
2406
by: Teddy | last post by:
Language: C Excel Reading Method: ExecuteReade I am currently running into a challenge reading excel data when datatype formats are different in the SAME column. It seems like datatype (in the...
2
12167
by: Griff | last post by:
When attempting to change the datatype for a datatable column with the following code: dtap.Columns(4).DataType = system.Type.GetType"System.String") I keep getting an error that says that I...
0
1628
by: vijayalakshmi.venkataraman | last post by:
Hello, I have a .NET client that accesses a Java webservice. Let me first say that the client stub I got generated from the wsdl was incomplete and had to make changes to it manually to make it...
0
1421
by: Priya | last post by:
hi all, I need to read the xml schema file and retrieve the sql:datatype element value in the xsd file. The schema file format is below <xsd:sequence> <xsd:element name="safe_job" type =...
4
11950
by: Orchid | last post by:
How can I change a Date datatype to a Number datatype? For example, I want a date 10/31/2006 to show 1031 as Number datatype. But I don't want it becomes 39021. What formula should I use? ...
11
21838
by: Matt F | last post by:
I'm trying to do something that seems like it should be pretty simple, but haven't found a solution. I am trying to add a datacolumn to a datatable that adds or subtracts a number of days based on...
0
7307
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7021
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7478
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1532
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
409
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.