Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

NULL value in column using bcp Expand / Collapse
Author
Message
Posted Friday, January 3, 2014 1:06 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Thursday, September 4, 2014 7:40 AM
Points: 3,546, Visits: 2,652
I am using bcp to insert data into a table. For just one column, i am getting NULL values as character 'NULL'. How can we deal with it ? I was checking in MS site and it gives one -k option which specifies that "empty columns should retain a null value during the operation, rather than have any default values for the columns inserted".

However I'm looking for a solution where the NULL should be treated as NULL value and not 'NULL' string for just one column. Can anyone suggest what to do ?
Post #1527373
Posted Friday, January 3, 2014 7:07 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Thursday, September 4, 2014 7:40 AM
Points: 3,546, Visits: 2,652
I'll try using blank value rather than NULL in txt file.
Post #1527515
Posted Friday, January 3, 2014 11:15 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 3:39 PM
Points: 37,101, Visits: 31,653
A NULL value in a CSV file is two delimiters with nothing between them. You're not using the actual word 'NULL' in your file are you? Also, do you have a trigger that might be converting a real NULL to the word 'NULL' in that one column?

--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1527785
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse