TinyTds::Error: String or binary data would be truncated

167 views
Skip to first unread message

André Lima

unread,
Feb 11, 2015, 5:57:19 AM2/11/15
to rails-sqlse...@googlegroups.com
Hello Friends,

I have this problem only on production. In developing executes normally.

TinyTds::Error: String or binary data would be truncated.: EXEC proc_diu_tmp_doc_ent_comp @w_operacao = 2, @w_dent_id = N'201540000000000021222NAC999999', @w_cid_id = 3850, @w_dent_com_ie = N'081271530', @w_dent_com_total_ipi = 0, @w_dent_com_total_icms = 0, @w_dent_com_id_entrada = 0, @w_dent_com_total_vlr = 1.0

Is there any specific adapter setting for production?

Thanks

Andre Lima

Ken Collins

unread,
Feb 11, 2015, 9:01:09 AM2/11/15
to rails-sqlse...@googlegroups.com
Andre,

Please do a quick google search on “String or binary data would be truncated” tagged with “SQL Server”. There are quite a few hits that talk about this problem. In general, your production DB looks like it has different column definitions for this operation. If you find this is not the case, please do a bit more investigation to see if this is indeed a FreeTDS/TinyTDS issue. 

My gut says it is not though. But if it is, please open a public issue here https://github.com/rails-sqlserver/tiny_tds/issues vs email. It is important to for you and others so that a larger community can see and help if needed. Cheers!


 - Ken
--
You received this message because you are subscribed to the Google Groups "Rails SQLServer Adapter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rails-sqlserver-a...@googlegroups.com.
To post to this group, send email to rails-sqlse...@googlegroups.com.
Visit this group at http://groups.google.com/group/rails-sqlserver-adapter.
For more options, visit https://groups.google.com/d/optout.

André Lima

unread,
Feb 11, 2015, 11:59:37 AM2/11/15
to rails-sqlse...@googlegroups.com
Hi Ken,

My database for production and development is the same. 

Only difference is the ruby version:
Server is: ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux]
Vagrant box: ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-linux]


--
Atenciosamente,

André Lima

KLausG

unread,
Feb 12, 2015, 1:45:20 PM2/12/15
to rails-sqlse...@googlegroups.com
And you are able to execute the mentioned SP call on your production system from SQL Server Management Studio??



Am Mittwoch, 11. Februar 2015 17:59:37 UTC+1 schrieb André Lima:
Hi Ken,

My database for production and development is the same. 

Only difference is the ruby version:
Server is: ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux]
Vagrant box: ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-linux]



On Wed, Feb 11, 2015 at 12:01 PM, Ken Collins <k...@actionmoniker.com> wrote:
Andre,

Please do a quick google search on “String or binary data would be truncated” tagged with “SQL Server”. There are quite a few hits that talk about this problem. In general, your production DB looks like it has different column definitions for this operation. If you find this is not the case, please do a bit more investigation to see if this is indeed a FreeTDS/TinyTDS issue. 

My gut says it is not though. But if it is, please open a public issue here https://github.com/rails-sqlserver/tiny_tds/issues vs email. It is important to for you and others so that a larger community can see and help if needed. Cheers!


 - Ken


On February 11, 2015 at 5:57:21 AM, André Lima (andreli...@gmail.com) wrote:

Hello Friends,

I have this problem only on production. In developing executes normally.

TinyTds::Error: String or binary data would be truncated.: EXEC proc_diu_tmp_doc_ent_comp @w_operacao = 2, @w_dent_id = N'201540000000000021222NAC999999', @w_cid_id = 3850, @w_dent_com_ie = N'081271530', @w_dent_com_total_ipi = 0, @w_dent_com_total_icms = 0, @w_dent_com_id_entrada = 0, @w_dent_com_total_vlr = 1.0

Is there any specific adapter setting for production?

Thanks

Andre Lima
--


--
Atenciosamente,

André Lima

André Lima

unread,
Feb 12, 2015, 2:01:32 PM2/12/15
to rails-sqlse...@googlegroups.com
No problem when I run from SQL Server Management Studio.

More details:

Enviroment:
Rails: 4.2.0
Ruby: ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux]
Database: SQLServer 2012, gem: activerecord-sqlserver-adapter, last version

Some considerations:

01 - I am running that procedure in my development environment and everything works fine.
02 - Database/user of production and development is the same.
03 - On the production server running the development environment also the same mistake.

Many Thanks 

Andre Lima


--
You received this message because you are subscribed to the Google Groups "Rails SQLServer Adapter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rails-sqlserver-a...@googlegroups.com.
To post to this group, send email to rails-sqlse...@googlegroups.com.
Visit this group at http://groups.google.com/group/rails-sqlserver-adapter.
For more options, visit https://groups.google.com/d/optout.



--
Atenciosamente,

André Lima

André Lima

unread,
Feb 12, 2015, 2:51:31 PM2/12/15
to rails-sqlse...@googlegroups.com
Friends,

Extract of my table and procedure 


Error:

TinyTds::Error: String or binary data would be truncated.: EXEC proc_diu_tmp_doc_ent_comp @w_operacao = 2, @w_dent_id = N'201540000000000021219NAC999999', @w_cid_id = 3850, @w_dent_com_ie = N'081271530', @w_dent_com_total_ipi = 0, @w_dent_com_total_icms = 0, @w_dent_com_id_entrada = 0, @w_dent_com_total_vlr = 10.0




Thanks

Andre Lima

KLausG

unread,
Feb 12, 2015, 3:39:47 PM2/12/15
to rails-sqlse...@googlegroups.com
Hi Andre,

I've just tested this litte PROC which works fine.
---
CREATE PROCEDURE CHAR_TEST( @c char(10) )
AS
BEGIN
    INSERT datatypes(char_10) VALUES(@c)
END

EXEC CHAR_TEST @c = N'1234567890xxxxxx'
---
( You can send more chars into this proc e.g. from Rails and they get truncated )

But as soon as your PROC declaration does not match your column declaration you will get the error message
Try to change the declaration to :
CREATE PROCEDURE CHAR_TEST( @c char(11) )

So I am quite sure, that the problem is in the column/proc declaration in your database.
BTW you gave us the PROC declaration from sara_db and the table declaration from sis_db.

Klaus

André Lima

unread,
Feb 12, 2015, 6:43:57 PM2/12/15
to rails-sqlse...@googlegroups.com
Klaus and friend,

I exclude the table and created again and it worked perfectly.

Many Thanks!!!!!

--
You received this message because you are subscribed to the Google Groups "Rails SQLServer Adapter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rails-sqlserver-a...@googlegroups.com.
To post to this group, send email to rails-sqlse...@googlegroups.com.
Visit this group at http://groups.google.com/group/rails-sqlserver-adapter.
For more options, visit https://groups.google.com/d/optout.



--
Atenciosamente,

André Lima
Reply all
Reply to author
Forward
0 new messages