06-22-2011 09:30 AM
Hi, I am looking to execute this SQL query between 2 different databases to update a local database based on data selected from a remote one.
e.g.:
- Local database name: db1
- local database schema: dbo
- local database table1
- remote database name: db2
- remote database schema: dbo
- Remote database table: table2
- Query: "SELECT * FROM db2.dbo.table2 WHERE NOT EXISTS(SELECT * FROM db1.dbo.table1)" <- This gets e the record set i would need to insert, and I already have a vi to do that kinda thing.
How do I go about this?
Thanks,
Mohamed
06-23-2011 05:16 PM
Mohamed,
There is a VI in the Database Connectivity Toolkit that allows you to execute SQL queries: DB Tools Execute Query.
http://zone.ni.com/reference/en-XX/help/370016E-01/lvdatabase/db_tools_execute_query/
Is this what you are looking for?
06-23-2011 05:37 PM
Well if you are asking how to do this with an SQL expression you can not. That is an SQL limitation. Some servers may have proprietary methods for that but I am not aware of this. Just select the data, save it to an array or cluster or whatever, then do an insert on the other table with the results.