Link to home
Start Free TrialLog in
Avatar of Simon Green
Simon Green

asked on

SQL Query Needed

Hi Experts!

Hope somebody could possibly help here? Im no SQL Expert and pulling my hair out trying to find an answer!

We have a SQL Database which has a Link Database to Google BigQuery. On the SQL Server I can run the following query which returns all the data.

SELECT * FROM OPENQUERY([BQ], 'SELECT * FROM dataviews.salesdata')

What I would like to be able to do is import all this data into a table in our SQL Database called SalesData.

I only want to insert the fields that have changed though (or don't exist).

Could somebody possibly help me with a SQL Statement

Thanks in advanced for any Help offered!
SOLUTION
Avatar of Mark Wills
Mark Wills
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Echo Mark's suggestion to bring the data on board where direct subsequent queries can be run.

Your question does not include enough detail dealing with logic, business process on whose basis the data you want versus the data you don't.

You further seem to be looking at comparing data  ........
An update using join to compare, update.

A sample illustration of data from one and sat from the other describing what the resulting data would look like, might help clarify your need and what the possible solution might be.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Simon Green
Simon Green

ASKER

Hi All!

Many thanks for everyones response.

To answer some of the questions ...

Mark Wills - Yes, SalesData Table already exists and is like for like on what will come from the BQ Query.
                      Table has the following Feilds
                      Data_1
                      Data_2
                      Data_3
                      Data_4
                      Data_5
                      Data_6
                      Data_7
                      Data_8
                      Data_1 is always Unique                    

Scot Pletcher - BigQuery seems to be a Royal PITA. I don't think at present (Maybe wrong) you can check for changes in the last x minutes.

Basically anything in the DB within BigQuery could change except Coloum_1 (Data_1)

The aim is to have onsite SQL with the data in. People will then query the SQL Box onsite. We have some site which have extremely low bandwidth and pulling the data live is just becoming un-workable.

Cheers!
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial