Wrox Programmer Forums
|
SQL Server 2008 General discussion of SQL Server *2008* version only - not related to a specific book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2008 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 26th, 2009, 09:06 AM
Authorized User
 
Join Date: Jul 2009
Posts: 20
Thanks: 0
Thanked 1 Time in 1 Post
Default T-SQL MERGE and OPENQUERY

Hi folks,

I am currently merging an MySql database table to an SQL Server database table. To access the MySql table I do use uses the OPENQUERY command. Getting the rows with OPENQUERY works fine so far. Inserting also with the following query:

INSERT INTO serverData (online, recorded, id, server)
SELECT [online], [recorded], [id], [server] FROM OPENQUERY(MYSQL, 'SELECT * FROM servercheck')

This has to be automatized. I want to update the the table serverData (which is in my SQL 2008 Server) with the results from the OPENQUERY. The table has to contain no duplicate rows.

I tried the merge statement a few times but it gives me an Incorrect syntax near the keyword 'INTO'.

Has anyone a solution?
 
Old December 3rd, 2009, 09:42 AM
Authorized User
 
Join Date: Jul 2009
Posts: 20
Thanks: 0
Thanked 1 Time in 1 Post
Default

I found a solution.

I used merge and I got the desired results, but as soon as I started to wait a few minutes and used merge again the script was processing and processing...

In my optionion MERGE is bugged or my implementation is not that perfect. I decided to drop the table every time, to re-create it and to make a simple insert.

Last edited by 4thhorseman; December 3rd, 2009 at 09:44 AM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
openquery syntax mpankuj SQL Server 2000 11 March 15th, 2010 01:27 AM
Using sp_execute with OpenQuery and Parameters BCullenward SQL Language 0 October 27th, 2008 03:48 PM
OPENQUERY Problem tsimsha SQL Server 2005 0 October 18th, 2007 06:18 AM
Openquery statements aven SQL Server 2000 2 January 11th, 2006 01:33 AM
openquery gr_chris SQL Server 2000 0 September 16th, 2005 08:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.