SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Cannot add certain integers to table


Cannot add certain integers to table

Author
Message
mcinwg
mcinwg
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 26
I have a table :

CREATE TABLE [dbo].[haEmails] (
[emailRef] [int] IDENTITY (1, 1) NOT NULL ,
[Sent] [bit] NOT NULL ,
[FromUserNum] [int] NOT NULL ,
[ToUserNum] [int] NOT NULL ,
[MessageType] [int] NOT NULL ,
[AddedAt] [datetime] NOT NULL ,
[SentAt] [datetime] NULL ,
[MessageText] [varchar] (600) NULL ,
[Version20091013] [bit] NOT NULL
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[haEmails] WITH NOCHECK ADD
CONSTRAINT [PK_TestEmails] PRIMARY KEY CLUSTERED
(
[emailRef]
) WITH FILLFACTOR = 90 ON [PRIMARY]
GO

ALTER TABLE [dbo].[haEmails] ADD
CONSTRAINT [DF_TestEmails_Sent] DEFAULT (0) FOR [Sent],
CONSTRAINT [DF_TestEmails_MessType] DEFAULT ((-1)) FOR [MessageType],
CONSTRAINT [DF_TestEmails_AddedAt] DEFAULT (getdate()) FOR [AddedAt],
CONSTRAINT [DF_haEmails_Version20091013] DEFAULT (0) FOR [Version20091013]
GO

My application wasn't always responding to an INSERT trigger on the table, and my investigations found that :

In Enterprise Manager, adding a new row :
haEmails(FromUserNum,ToUserNum,MessageType)
Values (22,11,-1)
fails, with message "string or binary data would be truncated".

But, Values (22,11,1) is successful.
In the range 1..250 I only get this behaviour for FromUserNum = 22 or 74 or 97, all other FromUserNum integers allow a negative MessageType value.

The criteria for failure appear to be :
(FromUserNum = 22 OR FromUserNum = 74 OR FromUserNum = 97)
AND MessageType < 0

Can anyone tell me what's going on and how to avoid the problem ?

Thanks in anticipation.
Mike C
Lowell
Lowell
SSC Guru
SSC Guru (70K reputation)SSC Guru (70K reputation)SSC Guru (70K reputation)SSC Guru (70K reputation)SSC Guru (70K reputation)SSC Guru (70K reputation)SSC Guru (70K reputation)SSC Guru (70K reputation)

Group: General Forum Members
Points: 70678 Visits: 40924
the error "string or binary data would be truncated". is specific to char/varchar fields...it doesn't have anything to do with integer fields.

since the command you are using doesn't even touch the sole varchar(600) column in your definition, I'd look to see if there are any triggers on the table...maybe there is a trigger that is updating something and it is failing.

Lowell
--help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!
jimmylee150
jimmylee150
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 3
sdsafdf

acheter viagra
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search