sql - "String or binary data would be truncated" error -


I am having an interesting problem, which was created a couple of weeks ago, with my SQL server. I use Crystal Reports to perform routine questions for my DB, and one of my reports has recently started failing and once again has started to succeed. Let me start by saying that I am not a true DBA, I am just taking this DB and Crystal Reports from someone else. I had not written a question in question.

I did some excavation, and I think the syntax that is causing the problem has been found. This is a long pending inquiry, so long as the request is not made, I will not be involved. This query pulls data based on today's day. For a few days, the query succeeds, and for some days it fails. When this fails, the error code is:

  string or binary data will be deducted  

Here the syntax is causing the problem is:

  @LastWeekDay declared as DATETIME set @LastWeekDay = (select case DatePart (weekdays, GETDATE ()) = 2 then cast (DATEADD (day - 3, GETDATE ()) date as) when DatePart (weekday, GETDATE ()) = 1, then cast (, -2 DATEADD (day, GETDATE ()) date as) ELSE Cast (DATEADD (day , -1, GETDATE () as the date)  

If I start manipulating this query, instead of using GETDATE, by entering static dates) function. I get mixed results. Today, the report is working, so if I throw at today's date, then it works, and gives me the result which I am looking for:

 < code> DECLARE @LastWeekDay aS DATETIME SET @LastWeekDay = (select case when DATEPART (weekday, "01/22/2015") = 2 then cast (DATEADD (day -3, "01/22/2015") Date of time (time of day, '1/22 ​​/ 2015') = 1 then cast (DATEADD (day, -2, '1/22/2015') DATE) ELSE CAST (DATEADD (day, -1, '1/22/2015' AS DATE) END)  

However, if I change the date from 1/2/21/2015, so it fails in this error code:

  (1 line affected) Message 8152, level 16, state 14, line 310 String or binary data will be deducted. The statement has been terminated.  

I went to issue 310, to see what the problem is. And here is code at 310.

  announced 308 @Queue table (LoanID varchar (8), LoanType varchar (12), CreditApproval DATE) 309 310 INSERT INTO @Queue (LoanID, LoanType, CreditApproval) select 311 312 "_364" LoanID , 313 "_1172" LoanType, 314 "_2300" CreditApproval  

I've tried increasing the number of characters on my field announcements, but it does not seem to work. I do not understand why the results of some dates are generated, and errors occur in a few days.

Here is a sample of the past few weeks, and the date that works / generates errors:

All dated 1/6 and the last seems to work fine. Can this cause the error?

Well, I got the problem at some point in my farm at one of the lengths of VECCAR (12) ) VARCHAR (25) had changed. For a few days, the prices were less than 12 characters, so there was no problem. On the second day, the price got more than 12, and when you tried to put it in the "Loan Type" field there was an error. In my manifesto, I changed the length of my area to 25 letters. Now I have no other problem. This is my new announcement.

  @Queue selected table (LoanID varchar (8), LoanType varchar (25), CreditApproval DATE) announced @Queue (LoanID, LoanType, CreditApproval) insert in "_364" loan ID " , "_1172" loan type, "_2300" credit acceptance FROM (((emdbuser.LOANXDB_S_02 s2 joined INNER. LOANXDB_S_06 s6 in SOLAFFID = s6.XrefId) Join INNER. LOANXDB_S_01 s1 ON s2.XrefId = s1.XrefId) insider Join emdbuser.LOANXDB_S_03 S3 on s2.XrefId = s3.XrefId) s2.XrefID Join insider emdbuser.LOANXDB_D_02 d2 = d2.XrefId  

there is also a And the announcement, and below was my query, where I was in the field Length was changed to 25. Now everything is fine.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -