September 2, 2011 at 4:57 am
I have a bulk insert statement for a csv, but this particular clients' data is making it difficult to import.
Its in the following format:
GREEN,0016861779528,"Dembo, Ron C","""Roulette"" or the Rules of Risk",0.00,,,"XX(205733.2)",2001,20100517,0,,
MAIN,0016861779528,"Dembo, Ron C","""Roulette"" or the Rules of Risk",0.00,,,"XX(205733.1)",2001,20020311,0,,
The two issues are the multiple Quotes and the Comma between Dembo and Ron C. Also not ALL will have the 3rd field, it could be blank.
Can I also strip the Quotes before it goes into the database?
Thank you
Darryl Wilson
darrylw99@hotmail.com
September 2, 2011 at 8:06 am
You can remove the quotation characters by utilizing the REPLACE function. For example:
DECLARE @IN VARCHAR(200)
SET @IN = 'MAIN,0016861779528,"Dembo, Ron C","""Roulette"" or the Rules of Risk",0.00,,,"XX(205733.1)",2001,20020311,0,,'
SELECT REPLACE(@IN,'"','')
Result:
MAIN,0016861779528,Dembo, Ron C,Roulette or the Rules of Risk,0.00,,,XX(205733.1),2001,20020311,0,,
A question. If what I assume is a name exists will their always be a comma between the first and last names, in effect making that fields 3 and 4?
September 2, 2011 at 2:25 pm
Darryl Wilson (9/2/2011)
I have a bulk insert statement for a csv, but this particular clients' data is making it difficult to import.Its in the following format:
GREEN,0016861779528,"Dembo, Ron C","""Roulette"" or the Rules of Risk",0.00,,,"XX(205733.2)",2001,20100517,0,,
MAIN,0016861779528,"Dembo, Ron C","""Roulette"" or the Rules of Risk",0.00,,,"XX(205733.1)",2001,20020311,0,,
The two issues are the multiple Quotes and the Comma between Dembo and Ron C. Also not ALL will have the 3rd field, it could be blank.
Can I also strip the Quotes before it goes into the database?
Thank you
If you'll post the CREATE TABLE statement for the data above, I'll show you how to do this.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply