1

Can we run multiple sql queries using Sqoop eval function?

For example:
sqoop eval -D mapreduce.job.queuename=NONP.XXXX --connect "jdbc:sqlserver://ee-dev/cloud.net:1433;database=sqlserver1" --username XXXX --password ABC --query 'drop table if exists table1;'select townid,stateid,countryid from town;'

Can some one suggest the solution to run the multiple queries in one sqoop EVAL?
If multiple queries are not possible in one Sqoop EVAL then i have to write multiple Sqoop Eval jobs.

jarlh
  • 42,561
  • 8
  • 45
  • 63
Sai
  • 97
  • 1
  • 2
  • 17

1 Answers1

0

A SQL Server client can usually send a batch of multiple statements instead of a single query. You would need to concatenate the statements in a single string, and separate them by whitespace. It's also a good practice to suppress the ROWCOUNT messages in a multi-statement batch. So something like:

--query 'set nocount on; drop table if exists table1; select townid,stateid,countryid from town;'

There are some restrictions on statements that can appear in a single batch. Certain DDL statements must be the first or only statement in a batch, and all the objects needed to parse the batch must exist at the beginning of the batch. You can work around both of these by using dynamic SQL inside the batch if necessary.

David Browne - Microsoft
  • 80,331
  • 6
  • 39
  • 67