openquery

Wide varchar field causes “Requested conversion is not supported” error using openquery with MySQL linked server

允我心安 提交于 2019-12-01 20:37:20
I'm trying to migrate a table from MySql to MSSQL using openquery but I keep getting the following error message: OLE DB provider "MSDASQL" for linked server "MYSQL" returned message "Requested conversion is not supported.". Msg 7341, Level 16, State 2, Line 1 Cannot get the current row value of column "[MSDASQL].description" from OLE DB provider "MSDASQL" for linked server "MYSQL". The SQL query I'm trying to run: insert into dbo.tickets (id, description, createdAt) select * from openquery(MYSQL, 'select * from mydb.tickets') With openquery I have already copied a couple tables but this one

Querying an Oracle database from SQL Server

好久不见. 提交于 2019-11-30 21:25:29
I have an Oracle 11g XE database that I would like to transfer into SQL Server Express 2005. At first I thought I'd just generate the tables in Oracle as SQL, manipulate the data formats, and run the query in SQL Server. This worked for small tables, but I have several tables with a few hundred thousands rows and some with millions of rows, so this solution won't work. I then created a TNS file with the following content: OracleTnsName = ( DESCRIPTION= ( ADDRESS = (PROTOCOL=TCP)(HOST=localhost)(PORT=1521) ) ( CONNECT_DATA = (SERVICE_NAME=XE) ) ) I followed instructions I found elsewhere on how

What is a “INSERT IGNORE” equivalent in MS SQL Server?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 11:34:50
I am trying to insert records into MySQL database from a MS SQL Server using the "OPENQUERY" but what I am trying to do is ignore the duplicate keys messages. so when the query run into a duplicate then ignore it and keep going. What ideas can I do to ignore the duplicates? Here is what I am doing: pulling records from MySQL using "OpenQuery" to define MySQL "A.record_id" Joining those records to records in MS SQL Server "with a specific criteria and not direct id" from here I find a new related "B.new_id" record identifier in SQL Server. I want to insert the found results into a new table in

Workaround for calling table-valued function remotely in SQL Server has even more issues

♀尐吖头ヾ 提交于 2019-11-30 08:48:04
I had a query with a set of parameters that needed to be run multiple times with different parameters, so I wrapped it in a table-valued function. That table valued function needed called from a remote server. Unfortunately, the call fails on the linked server with the error: Msg 4122, Level 16, State 1, Line 29 Remote table-valued function calls are not allowed. Microsoft has acknowledged that "calling a table-valued function remotely" was a feature left out of SQL Server 2008. See: http://connect.microsoft.com/SQLServer/feedback/details/276758/remote-table-valued-function-calls-are-not

What is a “INSERT IGNORE” equivalent in MS SQL Server?

独自空忆成欢 提交于 2019-11-29 17:03:10
问题 I am trying to insert records into MySQL database from a MS SQL Server using the "OPENQUERY" but what I am trying to do is ignore the duplicate keys messages. so when the query run into a duplicate then ignore it and keep going. What ideas can I do to ignore the duplicates? Here is what I am doing: pulling records from MySQL using "OpenQuery" to define MySQL "A.record_id" Joining those records to records in MS SQL Server "with a specific criteria and not direct id" from here I find a new

Workaround for calling table-valued function remotely in SQL Server has even more issues

家住魔仙堡 提交于 2019-11-29 12:21:00
问题 I had a query with a set of parameters that needed to be run multiple times with different parameters, so I wrapped it in a table-valued function. That table valued function needed called from a remote server. Unfortunately, the call fails on the linked server with the error: Msg 4122, Level 16, State 1, Line 29 Remote table-valued function calls are not allowed. Microsoft has acknowledged that "calling a table-valued function remotely" was a feature left out of SQL Server 2008. See: http:/

including parameters in OPENQUERY

时光总嘲笑我的痴心妄想 提交于 2019-11-26 04:12:24
How can I use a parameter inside sql openquery, such as: SELECT * FROM OPENQUERY([NameOfLinkedSERVER], 'SELECT * FROM TABLENAME where field1=@someParameter') T1 INNER JOIN MYSQLSERVER.DATABASE.DBO.TABLENAME T2 ON T1.PK = T2.PK From the OPENQUERY documentation it states that: OPENQUERY does not accept variables for its arguments. See this article for a workaround. UPDATE: As suggested, I'm including the recommendations from the article below. Pass Basic Values When the basic Transact-SQL statement is known, but you have to pass in one or more specific values, use code that is similar to the