Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 update question

Author  Topic 

DMarmolejos
Yak Posting Veteran

65 Posts

Posted - 2008-08-06 : 15:46:30
update Table1
set Grp = 'CADA'
where ItemCode LIKE '200%'



When I try to use this code, I get an error saying "String or binary data would be truncated"

(ItemCodes are nvarchar and typically look like this '200-abc-1545f')

any assistance is appreciated, thanks

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2008-08-06 : 15:55:13
Grp is probably a char(3) or varchar(3), 'CADA' won't fit

Jim
Go to Top of Page

DMarmolejos
Yak Posting Veteran

65 Posts

Posted - 2008-08-06 : 15:57:48
thanks, you are right

i just created Grp as a varchar without specifying anything

would you know how i can change the lenght?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-08-06 : 16:05:24
ALTER TABLE Table1
ALTER COLUMN Grp VARCHAR(4)



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

DMarmolejos
Yak Posting Veteran

65 Posts

Posted - 2008-08-06 : 16:09:30
yes thanks a lot!
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-08-07 : 04:04:51
quote:
Originally posted by DMarmolejos

thanks, you are right

i just created Grp as a varchar without specifying anything

would you know how i can change the lenght?


See what happens if you dont specify the length
http://sqlblogcasts.com/blogs/madhivanan/archive/2007/12/04/column-length-and-data-length.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -