I'm trying to import a set of flat files into an SQL server database. I downloaded and installed Oracle SQL Developer for Mac OS. I installed the proper plugin and can connect to the database fine, create tables and perform queries. The problem is I'm trying to use bulk insert to import some tab delimited files into the database. Thing is though, the bulk insert doesn't seem to work. The bulk insert code is as follows
BULK INSERT sessions
FROM '/.../sessions.txt'
WITH (FIELDTERMINATOR='\t',ROWTERMINATOR='\n')
That's the error log I get
Error starting at line 1 in command:
BULK INSERT sessions
Error at Command Line:1 Column:0
Error report:
SQL Error: Incorrect syntax near 'sessions'.
Error starting at line 2 in command:
FROM '/..../sessions.txt'
Error at Command Line:2 Column:0
Error report:
SQL Error: Incorrect syntax near the keyword 'FROM'.
Error starting at line 3 in command:
WITH (FIELDTERMINATOR='\t',ROWTERMINATOR='\n')
Error at Command Line:3 Column:0
Error report:
SQL Error: Incorrect syntax near '('.
BULK INSERT is a statement executed on the SQL Server. The file names involved are interperted in the context of the NT deployed SQL Server instance. '/.../sessions.txt' is not a valid NT filename, NT uses \ for directories delimiter in full path file names.
Try 0x0a as row terminator:
BULK INSERT sessions
FROM '/.../sessions.txt'
WITH (FIELDTERMINATOR='\t', ROWTERMINATOR='0x0a')
Related
Hi I am currently doing an automation testing script. And I have a portion where I would like to extract the data from the database and input them in text-fields.
This is how I have written my codes:
Retrieve and Input
Connect To Database Using Custom Params cx_Oracle '${Database Username}/${Database Password}#${Database Host}:${Database Port}/${DatabaseName}'
${ETD_Day}= Execute Sql String SELECT EXTRACT(DAY FROM 'DECL_UNBTHG_DT') FROM BAS_BERTH_APPLN_MASTER WHERE ABBR_VSL_M='APL';
Input Text ${FlexiStack_Day} ${ETD_Day}
Disconnect From Database
However when I am running for testing, this error showed up when trying to execute the sql string.
DatabaseError: ORA-00911: invalid character
I have tried to run the SQL statement in SQL developer and it works. May I know what is the issue here?
I have data in the data CSV File. I am trying to insert data from this csv data file into SQL Server Database Table.
I tried the below 2 options. Nothing is working for me.
1. BULK INSERT
2.BCP OPENROWSET
For Bulk Insert I am getting this below Error.
Msg 4861, Level 16, State 1, Line 1
Cannot bulk load because the file "\\ATACLS001PVFS\userdata$\haritha.pinninty\work\Test\Test.csv" could not be opened. Operating system error code 5(Access is denied.).
For BCP OpenRowSet, I am getting below Error.
Msg 7403, Level 16, State 1, Line 1
The OLE DB provider "Microsoft.ACE.OLEDB.12.0" has not been registered.
How to resolve these issues?
I am executing these Queries/Stored procedures from the SQL Server Query Analyser where i logged on using Windows Authentication.
I did not have Admin Priveleges on the machine yet.
Apprecaite your responses.
Thanks
Rita
Error message says it all,you need to download ACE Provider using below link.please note that this should be installed on machine where you are trying to import
https://www.microsoft.com/en-us/download/details.aspx?id=13255
You need admin Permissions to install
"For Bulk Insert I am getting this below Error."
Did you have the file open (i.e. Excel)? If so, close it from your desktop application.
I usually use the SQL Database Migration Wizard (SQLAzureMW) to script tables and then import them to a new database, as due to security rules I don't usually have a connection between the source and the target databases. However, this time I'm failing to use bcp to import some tables.
I dug further on it and created a temporary test database in the same machine that is hosting the source database. I tried to script a single table and import it, all using the SQLAzureMW. It works just fine and it also shows me the command that was used to import the .dat script file:
bcp.exe "dbName.dbo.tableName" in "c:\pathTo\dbo.tableName.dat" -E -n -C RAW -b 1000 -a 4096 -q -S targetServerAddress -U "dbUser" -P "dbPassword"
(Note I've manually redacted some variables above)
However, if I try to execute that very same command from the command line, it fails with the following error output:
SQLState = S0002, NativeError = 208
Error = [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Invalid object name 'dbName.dbo.tableName'.
SQLState = 37000, NativeError = 11529
Error = [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]The metadata could not be determined because every code path results in an error; see previous errors for some of these.
I'm sure there's no mistake in the connection or table name parameters, as in that case it would output "login failed" (wrong server, user, password or database name).
Is there any procedure run by SQLAzureMW before running the bcp command that I should execute too? It would be great if I could use that application just for importing, since I already have the .dat files...
Found the solution. Once finished the generation of scripts for the selected database tables, SQLAzureMW has an "SQL Script" tab. I've copied the whole script and executed in the empty database into which I wanted to import the .dat scripted tables. This script has instructions for creating the tables - apparently, the .dat files aren't doing that for an unknown reason, because I have repeated multiple times the backup process checking the option "Schema table with data".
Important to note that I didn't use to need that in older versions of the application. I can't re-test though because I have already updated it in every machine and I don't have access to download older releases anymore.
I am trying to use ogr2ogr to import GML file into SQL Server Spatial. I successfully import features with geometry, but I have few without geometry column. How can I import all of them?
EDIT:
I reinstalled GDAL, installed latest, works fine, but again cann't write non-spatial features.
Constantly getting error:
ERROR 1: Error creating layer: [Microsoft][ODBC SQL Server Driver][SQL
Server]Incorrect syntax near 'NULLCONSTRAINT'.
The error looks like incorrectly formed SQL statement, created by ogr2ogr against the SQL database.
Have you tried running SQL Server Profiler (within SQL Server) whilst you do the import? Assuming you run a standard trace, you will need to locate the row with NULLCONSTRAINT in the textData column in the trace output. Once you have found the problem statement, this should give you some idea how to fix the problem.
If you need a very simple tutorial on the Profiler this link might help
http://www.mssqltips.com/sqlservertutorial/272/profiler-and-server-side-traces/
A similar error for me was caused by square brackets in the shapefile name I was importing which meant the create table statement was invalid.
I'm trying to export data from hdfs text file to SQL Server using sqoop. When I have more than a couple of rows to insert it throws the following exception:
java.io.IOException: java.sql.SQLException: Incorrect syntax near ','.
at org.apache.sqoop.mapreduce.AsyncSqlRecordWriter.close(AsyncSqlRecordWriter.java:192)
at org.apache.hadoop.mapred.MapTask$NewDirectOutputCollector.close(MapTask.java:567)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:675)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:330)
at org.apache.hadoop.mapred.Child$4.run(Child.java:268)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:415)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1408)
at org.apache.hadoop.mapred.Child.main(Child.java:262)
Caused by: java.sql.SQLException: Incorrect syntax near ','.
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:368)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2820)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2258)
at net.sourceforge.jtds.jdbc.TdsCore.getMoreResul
I've checked the data for inconsistencies and i can't find anything strange.
I was wondering is the driver even supported?
The problem was being caused with the default way sqoop/jtds group multiple insert statements into 1 using comma separated list of values. This approach is not compatible with sqlserver 2005. To get around it I enabled jdbc-batch insert by providing --batch parameter.
The default way sqoop/jtds group multiple insert statements into 1 is supported with sqlserver 2008.
Also, when I tried the same thing (without the --batch argument) using ms-sql driver everything worked fine. Not sure how ms-sql-driver and sqoop work together to ensure compatibility with sql server 2005.