SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Sql row error
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

kbinay2009
Starting Member

India
3 Posts

Posted - 09/17/2013 :  03:44:15  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

3760 Posts

Posted - 09/17/2013 :  08:39:21  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000