November 1, 2011 at 11:25 am
I have a text file with the following header
DRG_FINAL,PAYOR,DISCH_SERVICE,DISCH_DATE,ENCOUNTER_COUNT
"209","BCCC","ORP",6/12/2011,1
"470","Medi","ORP",6/18/2011,4
"303","Other","URO",6/5/2011,1
How do I import this file to a table in SQL by using Import and Export Data (32-bit).
Thanks so much!
Hai
November 1, 2011 at 12:00 pm
right click the database -> Tasks -> Import Data.
From the data source select flat file and check the box that says the first row contains column names.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
November 1, 2011 at 1:58 pm
I did that, but still having the " " for the three cols, is there any way I could omit them while importing data to a table?
Thanx
November 1, 2011 at 2:02 pm
Well those characters are in your data. If you want to remove just update your table after your import.
Update MyNewTable
set DRG_FINAL = replace(DRG_FINAL, '"', ''),
PAYOR = replace(PAYOR, '"', ''),
DISCH_SERVICE = replace(DISCH_SERVICE, '"', '')
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
November 1, 2011 at 2:10 pm
Thanks.
November 2, 2011 at 3:49 am
on the flat file source, specify " as a text qualifier to have SQL strip out the " on the import
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply