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 2008 Forums
 Transact-SQL (2008)
 how to debug this issue. its urgent frenz

Author  Topic 

abivenkat
Starting Member

8 Posts

Posted - 2010-12-14 : 03:12:38
we have developed a project, in that project, when i login and click an UI, it is showing the following error. If i restart the service in the SQL server, then it is working fine. then again if i try to login after some time, it is showing the same error. restart the service, it'll work fine. it is not occuring when i run the project locally, but, it occurs in the server. i have any no idea about how to debug this. can anyone plz help me in solving this problem. its urgent

the error is:

String or binary data would be truncated. The statement has been terminated.

thankx in advanz

Kristen
Test

22859 Posts

Posted - 2010-12-14 : 03:15:30
You are trying to store a string value into a column that is too small to accommodate it. You will have to add tracking code to record / display what you are trying to store and then work out which piece of data is too large. (It might be Binary data, but most commonly this occurs with String data)
Go to Top of Page

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-12-14 : 03:49:16
quote:
it is not occuring when i run the project locally, but, it occurs in the server


Do you have the exact copy of database locally because many times in development we just test with few characters but in production user enters big strings.

As Kristen said, in one of the statement, the length of data is crossing the limit of column.

Have a look on how to debug stored procedure.
http://www.dotnetfunda.com/articles/article27.aspx

You can debug the stored procedure and can find out the statement that is causing the error and thereafter you can also check column length and length of data passed.
Go to Top of Page

abivenkat
Starting Member

8 Posts

Posted - 2010-12-14 : 04:16:15
hey kristen,
thanks for ur reply kristen and bohra..
kristen, u said tht we can use a tracking code to find the exact place wr the error is takin place. what kind of code is tht and wr i have to add it..
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-12-14 : 04:53:34
What Kristen means is for you to add code to the stored procedure to check the length of strings before inserting them into the tables. Once you find a case where string length > column size in table, that's a likely location for the error to have come from.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

abivenkat
Starting Member

8 Posts

Posted - 2010-12-14 : 08:18:54
one more thing..
this error occurs, when we try to login after certain time or for the first time in a day, if i restart the service in sql server, it works properly. error doesn't show up. if length is the only prob, then it shouldn't work at all,. but, working @ the 2nd time. why so?
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-12-14 : 08:36:29
Do you know yet exactly what code is causing it?

--
Gail Shaw
SQL Server MVP
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-12-14 : 08:57:06
Clearly something IS causing it. The reason will become clear when you find WHAT is causing it. Put some extra code in your application, or stored procedure, to track when an incorrect sized value is being used.

You may also be able to find it using SQL Profiler to see what data is being passed to SQL.
Go to Top of Page

abivenkat
Starting Member

8 Posts

Posted - 2010-12-15 : 00:59:02
still i cant find wt is causing this problem guys!!
is there any other alternatives to fix this instead of touching the code or stored procedures???
plz help..
thanx in advanz
Go to Top of Page

abivenkat
Starting Member

8 Posts

Posted - 2010-12-15 : 01:03:50
hey kristen,
what is SQL profiler men? what it can do? can i have any website address to study tht concept in brief?
Go to Top of Page

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-12-15 : 02:50:56
quote:
Originally posted by abivenkat

hey kristen,
what is SQL profiler men? what it can do? can i have any website address to study tht concept in brief?




From msdn:
Microsoft SQL Server Profiler is a graphical user interface to SQL Trace for monitoring an instance of the SQL Server Database Engine or Analysis Services. You can capture and save data about each event to a file or table to analyze later. For example, you can monitor a production environment to see which stored procedures are affecting performance by executing too slowly.

Have a look at:
http://articles.techrepublic.com.com/5100-10878_11-5054787.html
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-12-15 : 03:49:36
quote:
Originally posted by abivenkat

can i have any website address to study tht concept in brief?


Ever heard of Google?

--
Gail Shaw
SQL Server MVP
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-12-15 : 04:24:58
"is there any other alternatives to fix this instead of touching the code or stored procedures???"

This is what programmers do when they encounter bugs, surely? The fact that this is in any way difficult for you means that you need to build a framework in your application so that you can easily dig-down to find and diagnose the cause when things like this happen.
Go to Top of Page
   

- Advertisement -