Reputation: 11
I am trying to add a text file into SQL database table using BULK INSERT. BULK INSERT My_Tablename FROM 'C:\testing\temptest.txt' WITH ( FIELDTERMINATOR = '|', ROWTERMINATOR = '\n' ) GO But got error that 'do not have permission to use the bulk load statement'. Is there any alternative way to do it? I don't want to set TRUSTWORTHY ON or create certificate for BULK admin permission.
Upvotes: 1
Views: 1904
Reputation: 1890
Although @SQLChao definitely has the answer, I did not remember the location of said Import Data
option and simply opened the delimited file with my favorite text editor, Notepad++
and did the following find and replaces with Search Mode set to extended:
'
Replace: ''
|
Replace: ','
\r\n
Replace: ')\r\n
\r\n
Replace: \r\nINSERT INTO [DB_Name].[Schema_Name].[Table_Name] VALUES(\r\n'
The only issues should be in your first and last insert statements which can manually be edited as need be.
I then copied the text straight into Sql Server and executed.
Upvotes: 1
Reputation: 7847
Try using the SQL Server Import and Export Wizard.
Upvotes: 2