I am exporting the data from hive table to SQLServer table using sqoop, but at times all the records do not get exported.

I'm not sure how to identify this failure without manual intervention. I have a plan to solve this issue by writing a shell script that -

1) Stores the count of hive table in a variable.
2) Stores the count of SQL Server table in another variable.
3) Compares the value of the two variables, 

```
    if var1 != var 2 
    { 
       Delete the rows in SQL Server Server;
        Rerun my sqoop script
    }
    else
       exit;

```

Questions: 
With my current approach,
How to store the count of rows of a hive table in a variable in a shell script?
How to store the count of rows of a table in SQL-Server-Management studio in a shell script?