School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,466 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,711 people online right now. Registration is fast and FREE... Join Now!




What's wrong with my sql query?

 

What's wrong with my sql query?

Obay

14 Jun, 2009 - 08:43 PM
Post #1

New D.I.C Head
*

Joined: 28 Jan, 2009
Posts: 23



Thanked: 1 times
My Contributions
hi...i've made a query for inserting a new table,..the code is:

CODE

create table #TMP_PPB
(Nopo nvarchar (45),Kontrak nvarchar (45),
Metode nvarchar (45),Mulai datetime,Akhir datetime,
Perusahaan nvarchar (45),
UK nvarchar (5),USD numeric (19,6),IDR numeric (19,6),
Jenis nvarchar (45),Unit numeric(19,6),Satuan nvarchar (45),UnitPrice numeric(19,6),
Percentage nvarchar (15))

insert into #TMP_PPB
(Nopo,Kontrak,
Metode,Mulai,Akhir,
Perusahaan,UK,
USD,IDR,
Jenis,Unit,Satuan,UnitPrice,
Percentage)
exec
('select distinct a.u_pono,a.u_scopeofwork,
b.descr,a.taxdate,d.taxdate,
c.cardname,c.cardfname,
a.doctotal,a.doctotalfc,
e.dscription,e.quantity,
e.unitmsr,e.u_userprice,
f.sww
from opor a
full join ufd1 b on a.u_procmethod=b.fldvalue and b.fieldid=25
full join ocrd c on a.cardcode=c.cardcode
full join opdn d on a.u_pono=d.u_pono
inner join por1 e on a.docentry=e.docentry
inner join (select distinct a.docentry,a.itemcode,b.sww from por1 a
            inner join oitm b on a.itemcode=b.itemcode)f on a.docentry=f.docentry
')


i used sql server 2005.
when i execute the query an error message appear

"Msg 8152, Level 16, State 13, Line 1
String or binary data would be truncated.
"

can u tell me what should i do?

thankyu for your help
regards,

obay

User is offlineProfile CardPM
+Quote Post


Martyr2

RE: What's Wrong With My Sql Query?

14 Jun, 2009 - 08:53 PM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 7,246



Thanked: 820 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
It means that one of the fields of your table (a string field most likely) is too small for the amount of text data you want to insert into it.

So check your text field lengths (you have some that are 45 in length and one that is 15 in length) and then check the data you are trying to insert into this table is not longer than 45 characters for the 45 character fields or longer than 15 characters for your 15 character field.

The error is basically telling you that since your data you are trying to insert is longer than the field limit, it is going to truncate that data to make it fit.

smile.gif
User is offlineProfile CardPM
+Quote Post

arsh_aarsh

RE: What's Wrong With My Sql Query?

14 Jun, 2009 - 09:01 PM
Post #3

New D.I.C Head
*

Joined: 12 Oct, 2008
Posts: 36



Thanked: 6 times
My Contributions
Any of the fields that you are inserting has got text of more characters than that specified for that field in theb create statement.

eg. if you have specified the size if a field as 15 in the create statement, the size of the value that you are inserting for that field is more than 15.

Just map the field sizes in the create and insert statement.
User is offlineProfile CardPM
+Quote Post

Obay

RE: What's Wrong With My Sql Query?

14 Jun, 2009 - 10:38 PM
Post #4

New D.I.C Head
*

Joined: 28 Jan, 2009
Posts: 23



Thanked: 1 times
My Contributions
thankyu for the answer Martyr2 & arsh_aarsh, you both alright...my query generate success full then... biggrin.gif icon_up.gif

This post has been edited by Obay: 14 Jun, 2009 - 10:49 PM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 02:33AM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month