Importing a pipe delimited text file into  table using sql not wizard

Fordraiders
Fordraiders used Ask the Experts™
on
Sql server 2008r2

Can anyone point me to a good example of
importing(insert) a pipe delimited text file in to a table.

Not using the import wizard please.
and i cant use Bulk insert
approx 12 million records

Thanks
fordraiderds
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Doug BishopDatabase Developer

Commented:
Why not the wizard or bulk insert. They certainly can handle 12M rows. You can use SSIS, which is basically what the wizard does (it creates an SSIS package). I suppose the only other option is using bcp.

Author

Commented:
because i do not have rights to use Bulk insert..
Doug BishopDatabase Developer

Commented:
Can you use bcp? It is a command line utility for importing data.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
No, i need just to use a INSERT text file from  a location on c: drive.
Doug BishopDatabase Developer

Commented:
We'll if you can't it's bcp, bulk insert, the wizard (which means you can't use ssis), is say your only option is to make the file available to a DBA who has access and have them in the file for you.
If they have your access that locked down there isn't anything you can really do.
Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015

Commented:
You would need external tools (Database Browser), for example) or scripts (e.g. PowerShell code) to go without. Both are implementing single row INSERT statements, and hence are slower than the bulk tools.
Doug BishopDatabase Developer

Commented:
My thoughts are, if they don't have access to bcp, bulk insert, the import wizard, they are probably locked out of being able to access the server/database through PowerShell or other 3rd party tools.
I've worked as a database developer in shops where I've needed to get DBAs involved to do one-time imports into a production environment. Most production ETL environments run under a service account that has access to tools to do the import and export of files.

Author

Commented:
bulk insert [dbo].[CRS_Header_Detail_Current_Staging_024]
from 'C:\Users\Public\Documents\Data dump Performance Report 10DEC2018.txt'
with (fieldterminator = '|', rowterminator = '\n',KEEPNULLS)
go

got bulk insert rights..
but now error:
Msg 4864, Level 16, State 1, Line 1
Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 2 (PROJECT_SUBMIT_DATE).
Database Developer
Commented:
Add FIRSTROW=2 to skip reading the header row.
with (fieldterminator = '|', rowterminator = '\n',KEEPNULLS, FIRSTROW=2)
Doug BishopDatabase Developer

Commented:
Also, it appears that the row terminator is actually CR/LF which should be \r\n instead of just \n. It will work with just the \n but the carriage return would be imported in as part of UPDATEDBY, so instead of br1tim, it would actually come in as br1tm\r.

Author

Commented:
thanks doug/all  very much!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial