Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have a linked server registered in my SQL Server 2005 which accesses our SAP database (test system). It uses an ODBC driver provided by SAP, and is connected using the Microsoft OLEDB For ODBC driver. The remote database is a MaxDB 7.7.

I'm currently exploring the possibilities of directly accessing data within our SAP system, but have run into problems regarding certain tables.

The following works without problems:

SELECT Field FROM LinkedServer..Schema.Table WHERE MANDT = '110'

or, respectively

SELECT * FROM OPENQUERY(LinkedServer, 'SELECT Field FROM Table WHERE MANDT = ''110''')

Now, there's some nasty table names within SAP that can contain slashes. I think it's meant to be a "namespace" type of thing contained within the actual table name. On the ABAP side of things, I can easily do

SELECT * FROM /MYWHATEVER/MYTABLE

provided the table exists. But I can't get the table names containing / working via linked server.

Trying

SELECT * FROM OPENQUERY(LinkedServer, 'SELECT * FROM /MYWHATEVER/MYTABLE')

gives me "Error 7321 while preparing query...". Using

SELECT * FROM LinkedServer..Schema.[/MYWHATEVER/MYTABLE]

yields "Error 7306 OLEDB-Provider "MSDASQL" can't open table "Schema./MYWHATEVER/MYTABLE" for linked server LinkedServer, it contains errors or doesn't exist".

Is there any way I can access tables containing / on a MaxDB via LinkedServer?

[The error messages may not be literally the same as on an english system, since I had to translate them from german]

share|improve this question
    
Does it work if you quote the table name (using single-quotes as per the ANSI standard)? –  Gonsalu Oct 27 '11 at 17:43
    
@Gonsalu Thanks for the hint, masking using double quotes " works for one of the two cases, see my comment on gbn's answer. –  takrl Nov 9 '11 at 13:50
add comment

1 Answer

I'd try escaping stuff and see what happens

SELECT * FROM OPENQUERY(LinkedServer, 'SELECT * FROM //MYWHATEVER//MYTABLE')
SELECT * FROM OPENQUERY(LinkedServer, 'SELECT * FROM \/MYWHATEVER\/MYTABLE')
...

I assume that the local ODBC layer is bollixing you. The bit inside OPENQUERY should be a literal to SQL Server so it is external to SQL Server. So it could be be the ODBC layer: can you profile (or log) what happens on the MaxDB to see what gets through?

Another option would be use a view or proc in the MaxDB to give "proper" names

share|improve this answer
    
Thanks, after experimenting for a while, it seems that using " to mask the table names works when using the OPENQUERY syntax like this: SELECT * FROM OPENQUERY(LinkedServer, 'SELECT * FROM "//MYWHATEVER//MYTABLE"'). No luck using that on the three dot syntax though, SELECT * FROM LinkedServer..Schema.["/MYWHATEVER/MYTABLE"] still does not work. No luck with profiling/logging yet, I'd need someone from the SAP team to look at that. –  takrl Nov 9 '11 at 13:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.