473,569 Members | 2,731 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 1339
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
11869
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 it might be a few weeks until we get the patch.
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 problem. I create a blank database (TestDB) under my server machine (SQL Server 2000 Standard)... I then create a new table (Run_Number) with only one...
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 a native DS datatype" could anyone help me with this please. i already passed two days trying to figure out what is the problem.
8
1939
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 extra thing to. The datatype is a class I made. Is there anyway for me to test a parameters datatype in a template using function?
1
2409
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 OleDbDataReader schema) is set by the first data row and that causes a problem if any of the subsequent rows in that column holds a diffrent datatype...
2
12170
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 can't change the datatype because there is data in the table. However, I know there is no data in the table, as I have cleared the table and tested...
0
1638
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 work to an extent. I generated a java client stub for the java web service and have been modifying my .NET client stub using the java client stub...
0
1426
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 = "xsd:string" sql:datatype="varchar(255)" /> </xsd:sequence>
4
11955
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? Thanks for your help!!
11
21866
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 another datetime column in the table. See sample below. How do I do this? Any help would be greatly appreciated. Thanks Private Sub...
0
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8122
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7673
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6284
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2113
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 we have to send another system
1
1213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.