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
 General SQL Server Forums
 New to SQL Server Programming
 SQL ERROR

Author  Topic 

ori_davidson
Starting Member

15 Posts

Posted - 2014-09-28 : 06:04:16
that's the query:

update u
set u.jrnlmemo=d.CardName
from oinv u inner join OCRD d on u.CardCode = d.CardCode
where d.QryGroup45 ='Y' or d.GroupCode =119 or d.GroupCode =108

I am getting this ERROR:
Msg 8152, Level 16, State 13, Line 1
String or binary data would be truncated.
The statement has been terminated.

THANKS,
ORI

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-09-28 : 07:53:42
Card name is longer than jrnlmemo
Go to Top of Page

ori_davidson
Starting Member

15 Posts

Posted - 2014-09-28 : 08:11:18
i guess i need the function CAST - how do I use it here?
THANK YOU VERY MUCH
Go to Top of Page

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-09-28 : 17:34:51
You may or may not need to CAST the column. It depends on the datatype. Can you please post CREATE TABLE commands for both tables in the query?
Go to Top of Page

ori_davidson
Starting Member

15 Posts

Posted - 2014-09-29 : 00:18:15
is it possible to set only 10 char. in the OCRD table, I don't need the whole name.
Go to Top of Page

ori_davidson
Starting Member

15 Posts

Posted - 2014-09-29 : 03:48:03
Hi again, can I write something like :
LINE 2: set u.jrnlmemo= cast(d.CardName as char(10))
I'm doing something wrong because - Its not working...


update u
set u.jrnlmemo=d.CardName
from oinv u inner join OCRD d on u.CardCode = d.CardCode
where d.QryGroup45 ='Y' or d.GroupCode =119 or d.GroupCode =108
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2014-09-29 : 04:07:10
Basically you need to match the length of CardName to jrnlmemo. Using substring() will be more appropriate if both the columns have same datatypes.

update u
set u.jrnlmemo= substring(d.CardName,1,10)
...


Harsh Athalye
http://in.linkedin.com/in/harshathalye/
Go to Top of Page

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-09-29 : 09:37:57
again, please post the CREATE TABLE statements for the tables involved in the query
Go to Top of Page

ori_davidson
Starting Member

15 Posts

Posted - 2014-09-29 : 09:46:01
WORKED!!!

THANX!!
Go to Top of Page
   

- Advertisement -