Cannot add certain integers to table

  • 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

  • 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!

  • sdsafdf

    acheter viagra[/url]

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply