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 2005 Forums
 Transact-SQL (2005)
 Sql row error

Author  Topic 

kbinay2009
Starting Member

3 Posts

Posted - 2013-09-17 : 03:44:15
I have a .net application which copies data from excel file to sql table. WHile uploading data, I got an error message in my app and while checking the table, I found the following:

I have a column name empid in the sqltable which will be null after uploading. but one row in the table showning blank instead of null
to know the length of the field, I update the null values to blank.
Now I find the length using len function in sql. To My surprise, all fields showing 0 length except one field which is showing 2.
For this reason I am getting an error as the field is not blank. But there is nothing written in the particular field. So, can you help me to trace that problem and it's solution.


with regards,
Binay.

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-09-17 : 08:39:21
See what is in that row using a query like this:
SELECT * FROM YourTable WHERE LEN(empid) > 1
Once you find that row, see what is in the empid column. If it is a non-printing character, see what it is by casting it to varbinary.
SELECT CAST(empid AS VARBINARY) FROM YourTable WHERE LEN(empid) > 1
Look up ASCII key codes to see what those characters are: http://www.asciitable.com/
Go to Top of Page
   

- Advertisement -