|
-
April 25th, 2007, 11:27 PM
#1
Insert errors
Hi,
I have a basic insert statement like this,
INSERT INTO TRANS ( pin , date , time , type , amount , descr , userid ) VALUES ( '111111' , '20070425' , '230904' , '1Œ' , 3100 , '' , 'TEST' )
The table structure of TRANS is
CREATE TABLE [dbo].[trans] (
[pin] [char] (12) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[date] [char] (8) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[time] [char] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[type] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[amount] [int] NULL ,
[descr] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[userid] [char] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
The insert is successful on one machine and gives error on one machine.
The error is as follows.
Insert String #8152: String or binary data would be truncated.
I understand that it is complaining that it cannot put '1Œ' value into a char 1 field. But my question is how is it working on the other machine. I traced the table with the profiler and I get the same kind of insert statement on both the machines.
Please help.
Thanks.
-
April 25th, 2007, 11:28 PM
#2
Re: Insert errors
I am using SQL 8.0 on both the machines.
-
April 26th, 2007, 10:27 AM
#3
Re: Insert errors
Here are the version details of both the machines if that helps.
DOES NOT WORK ON
Microsoft SQL Server 2000 - 8.00.760 (Intel X86)
Dec 17 2002 14:22:05
Copyright (c) 1988-2003 Microsoft Corporation
Standard Edition on Windows NT 5.0 (Build 2195: Service Pack 4)
WORKS ON
Microsoft SQL Server 2000 - 8.00.194 (Intel X86)
Aug 6 2000 00:57:48
Copyright (c) 1988-2000 Microsoft Corporation
Developer Edition on Windows NT 5.1 (Build 2600: Service Pack 2)
Does the standard edition and developer edition make any difference.
If so how do I fix it. Any help is appreciated.
-
April 26th, 2007, 10:05 PM
#4
Re: Insert errors
I the same collation used on both servers?
-
May 7th, 2007, 11:58 AM
#5
Re: Insert errors
this is the general error you get wen u are passing any string value more in length than the columns allocated length.
for example:
column name Col1 Char(20)
and u are passing the value to be inserted as 'aaaaaaaaaaaaaaaaaaaaaaaa'
here the length passed is 24 chars and the column length is char (20) only.
such cases in general gives the error you mentioned. still am not sure if this is the cause of ur error or not.
Whenever I hear "It can't be done", I know, I am close to success!! 
-
May 7th, 2007, 12:01 PM
#6
Re: Insert errors
i was just looking in the code u provided, just chek the length of the type column and the value u are passing to it.
column length is char (1) and the value u are passing is 'ICD' so it comes to 3 chars... and hence the error... hope this helps u solving ur probs...
take care!!
Whenever I hear "It can't be done", I know, I am close to success!! 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|