question

Fatherjack avatar image
Fatherjack asked

Linked server query returns error on first execution

Hi, we have recently had a system upgrade and move the accompanying database from 2008 R2 (10.50.4000) to 2012 (11.0.3000). One of the system admins created a linked server from the old server to the new one and then ran a TSQL query against 2 tables in the new database. This query always returns the correct results but on its first execution it also returns an error: > Msg 105, Level 15, State 1, Line 1 > Unclosed quotation mark after the character string '{d174b015-8602-e411-'. > Msg 102, Level 15, State 1, Line 1 > Incorrect syntax near '{d174b015-8602-e411-'. - Subsequent executions return the same results but with no error. - If the query is edited and executed against only one table there is no error. - If the whole query is executed from the 2012 server then there is never an error - There is no value in the data of the joined columns that is close to the value in error (yes, the join is on a GUID column. I cant help that, its a 3rd party system). The query is : SELECT TOP(11) usr.Company from [LinkedServer].database.dbo.user usr left join [LinkedServer].database.dbo.common com on com.[ID] = usr.[ID] - Changing the TOP number results in the error for the first execution but for no subsequent ones. - Removing the TOP has the same effect as prev point. - Changing to an inner join has the same effect. - Creating a linked server on from 2012 doesn't have any such issues. Has anyone seen this issue and/or identified how to avoid it?
sql-server-2008-r2sql-server-2012linked-server
7 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

So, I have located the issue and can repro. I'm pretty sure its an edge case bug so will open a connect item when I get a chance.
1 Like 1 ·
I'm glad you at least figured out the cause if not the solution. Please add an answer with either a solution if you get one or a link to the connect article and an explanation of the cause. Thanks.
1 Like 1 ·
Can you add the script of the linked server please?
0 Likes 0 ·
I've got nothing. Data on the linked server? Grasping at straws.
0 Likes 0 ·
@Fatherjack the 11.0.3000 = SP1 build is more than 2 years old, November 2012. Same applies to the 2008 R2 = SP2 build from July 2012. Is it at all possible that updating SQL 2012 to SP2 and/or updating the 2008 R2 to SP3 might address this issue?
0 Likes 0 ·
Show more comments

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.