May 4, 2009 at 11:29 am
Hello everyone,
When one developer tried to update the records using Management studio, got error:String or binary data would be truncated. I have checked that data type is varchar(255). The orginal data is 28 characters. He just updated one letter from lower case to upper case.
And then I tested on another database. the weird thing is even though in the same table,same column, some records are able to be modified and some get the same error.
Does anybody know what is happening? BTW, SQl server is 2005 SP3.
Thanks
May 4, 2009 at 11:34 am
Perhaps a trigger causing this?
May 4, 2009 at 11:37 am
Have you tried issuing the update statement, for the same row, from T-SQL?
May 4, 2009 at 11:39 am
No Triggers
May 4, 2009 at 11:42 am
David (5/4/2009)
Have you tried issuing the update statement, for the same row, from T-SQL?
Yes, they are working.
May 4, 2009 at 11:44 am
I think at this point that we're going to need to see the data being modified. It would also help to see the table structure, and the command(s) being issues in SSMS.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
May 4, 2009 at 11:45 am
Then what's probably happening is that the management window is updating multiple records at a time, based on what it sees as the primary key to the table. When you write the update statement in TSQL, its being limited to just the row you are trying to update, and everything works as advertised.
Try running profiler, and doing the update through the management window; that may shed some light on what's happening.
May 4, 2009 at 11:52 am
WayneS (5/4/2009)
I think at this point that we're going to need to see the data being modified. It would also help to see the table structure, and the command(s) being issues in SSMS.
Table structure
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[tbl_pages](
[page_id] [int] NOT NULL,
[image_id] [int] NULL,
[pdf_e] [varchar](255) NULL,
[pdf_f] [varchar](255) NULL,
[text_e] [text] NOT NULL,
[text_f] [text] NULL,
[intro_e] [text] NULL,
[intro_f] [text] NULL,
[next_page] [smallint] NOT NULL CONSTRAINT [DF_tbl_pages_show_next_page] DEFAULT (0),
[prev_page] [smallint] NOT NULL CONSTRAINT [DF_tbl_pages_prev_page] DEFAULT (0),
CONSTRAINT [PK_tblPages] PRIMARY KEY CLUSTERED
(
[page_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
I just updated column "PAF_e" from null to letter 'n'
May 4, 2009 at 12:09 pm
sql profile trace result like below when I am using management studio to update record. from the trace, I can see it was really tring to update only one resoce at the same time.
see my last reply to see table structure.
exec sp_executesql N'UPDATE tbl_pages SET pdf_e = @pdf_e WHERE (page_id = @Param1) AND (image_id IS NULL) AND (pdf_e IS NULL) AND (pdf_f IS NULL) AND (text_e LIKE @Param2) AND (text_f LIKE @Param3) AND (intro_e LIKE @Param4) AND (intro_f LIKE @Param5) AND (next_page = @Param6) AND (prev_page = @Param7)',N'@pdf_e nvarchar(1),@Param1 int,@Param2 nvarchar(3265),@Param3 nvarchar(max) ,@Param4 nvarchar(345),@Param5 nvarchar(422),@Param6 smallint,@Param7 smallint',@pdf_e=N'n',@Param1=3,@Param2=N'orginal text',@Param6=0,@Param7=0.
the error message is
"No row was updated.
the data in row 1 was not commmited.
error Source: .Net SqlClient data Provider
Error Message: String ot binary data would be reuncated
The Statement has been terminated.
Correct the errors and retry or press ESC to cancel the change(s)."
May 4, 2009 at 12:18 pm
So, that's the equivalent of
update tbl_pages set pdf_e ='n'
where page_id =3 and image_id is null and pdf_e is null and pdf_f is null and text_e like 'orginal text' and text_f like <> and intro_e like <> and intro_f like and next_page = 0 and prev_page = 0.
I couldn't see the values for a couple of the variables in what you posted, but I may have missed something there. But, what you're saying is that if you run that update statement, it will only update one row? Try running that (make sure to put the in the values for text_f and intro_e), and see what happens.
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply