Solved

Msg 7321, Level 16, State 2, Line 1 occurs on only one of three servers

Posted on 2008-10-02
2
1,111 Views
Last Modified: 2013-12-06
I have three Microsoft SQL Servers 2005 Enterprise Edition.
We installed IBM DB2 UDB for iSeries IBMDA400 OLE DB Provider version 10.124.107.200 on all of them.
We created the linked server PS_DWH using this provider to perform queries agains a DB2 database.
On one of those servers, I'm having issues to run the following query:

select * from openquery(ps_dwh,'select substring(abalph,2,4) from proddta.f0101')

It raises the following error:

OLE DB provider "IBMDA400" for linked server "ps_dwh" returned message "SQL0104: Token ,2 was not valid. Valid tokens: , FROM.
Cause . . . . . : A syntax error was detected at token ,2. Token ,2 is not a valid token. A partial list of valid tokens is , FROM. This list assumes that the statement is correct up to the token. The error may be earlier in the statement, but the syntax of the statement appears to be valid up to this point. Recovery . . . : Do one or more of the following and try the request again: -- Verify the SQL statement in the area of the token ,2. Correct the statement. The error could be a missing comma or quotation mark, it could be a misspelled word, or it could be related to the order of clauses. -- If the error token is <END-OF-STATEMENT>, correct the SQL statement because it does not end with a valid clause.".
Msg 7321, Level 16, State 2, Line 1
An error occurred while preparing the query " 
select substring(abalph,2,4) from proddta.f0101
" for execution against OLE DB provider "IBMDA400" for linked server "ps_dwh".

If I add spaces among the substring function's parameters, the query works:

select * from openquery(ps_dwh,'select substring(abalph, 2, 4) from proddta.f0101')

Does anybody know why?

Remembering that it works on the other two SQL Servers, it doesn't matter whether the spaces exist or not. Do I need to set something?

Thanks,

Felipe
0
Comment
Question by:Carlos_Felipe
2 Comments
 
LVL 26

Expert Comment

by:Zberteoc
ID: 22626603
I'm just guessing here, does the problem SQL server have the same collation with the other two?
0
 

Accepted Solution

by:
Carlos_Felipe earned 0 total points
ID: 22626919
Yes, they all have the sam collation.

I figured that out!

The linked server must be set to "Be made using this security context" with a specific remote login and password.

Thanks for your attention!

Felipe
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now