Problem with SQL linked server

Blakey43

New Member
Hi,

I've got a Progress V9.10E database running on a Windows Server 2003 R2 machine. I've set up a linked server to this on a SQL Express 2008 32-bit database running on a WIndows Server 2008 R2 64-bit virtual machine.

I'd like to set up a db view on the SQL server, so I can use the data in another application. I've already done this on one of the smaller Progress tables and it works OK. However, when I try to query a large table, the query just runs and runs and doesn't return the data in any reasonable time. I'm trying to use Openquery to improve things, but I have problems with the quotation marks, I think.

Here's my SQL stored procedure code:
@SQL1 varchar(500) = '',
@SQL1a varchar(500) = '',
@SQL1b varchar(500) = '',
@SQL2 varchar(4000) = '',
@Warehouse varchar(4) = "GC",
@TrxType varchar(3) = "D"

SET @SQL1 = '''SELECT a."chamber-code", a."receipt-date", a."gen-dec", b."fromto-cust" FROM INDEXREADONLY..PUB.Entryheader AS a INNER JOIN INDEXREADONLY..PUB.Booking AS b ON a."booking-no" = b."booking-no" WHERE a.warehouse = '''

SET @SQL1a = ''' AND a."Trx-no" > 100000 AND a."Trx-type" = '''

SET @SQL1b = ''' AND a.Confirmed = 0'''

SET @SQL2 = 'SELECT * FROM OPENQUERY(INDEXREADONLY, '+ @SQL1 + @Warehouse + @SQL1a + @TrxType + @SQL1b +')'

PRINT @SQL2

EXEC(@SQL2)

I broke the query statement into bits trying to overcome problems, but no luck. The query runs absolutely fine on the Progress DB itself using SQL Explorer, but I get an error from SQL. Here is the SQL output:

SELECT * FROM OPENQUERY(INDEXREADONLY, 'SELECT a."chamber-code", a."receipt-date", a."gen-dec", b."fromto-cust" FROM INDEXREADONLY..PUB.Entryheader AS a INNER JOIN INDEXREADONLY..PUB.Booking AS b ON a."booking-no" = b."booking-no" WHERE a.warehouse = 'GC' AND a."Trx-no" > 100000 AND a."Trx-type" = 'D' AND a.Confirmed = 0')

Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'GC'.

Any help will be welcome!
Thanks,

Steve
:)
 

Blakey43

New Member
Hi,

Thanks for viewing this thread. I got an answer on a SQL Server Central forum. The problem was the quotes around the variables @Warehouse and @TrxType. This was fixed by using the Quotename function. I also needed to stop using the four-part name within the @SQL1 string, since the Openquery function handles the Linked server name.

Steve
 

Blakey43

New Member
How did you link the servers?

I linked them in the standard way through SQL Server Management Studio. I needed a System DSN to do that, so I had to install Progress onto the same server in order to get the ODBC driver.

Regards,
Steve
 

madhead

New Member
Any chance you could email me a screen shot of the management studio settings?

I have managed to get the progress Open Edge 10.2A odbc drivers working in terms of I can open the database through them in Excel or c# etc. But I cannot seem to get the settings correct in SQL Server Management Studio.

Sorry to jump on your thread but I have been searching everywhere on what to type in the boxes and nothing thus far has worked for me :-(

cheers
Andy

madhead (@at) gmail (.dot) com
 

Blakey43

New Member
I tried to upload a screenshot picture but as soon as I click on "Manage attachments" I get an interminable error message saying "UndefinedYou do not have permission....." etc. I tried making an album and uploading that way but got the same message. Can any moderators reading this please help?
Thanks,
Steve
 

antonio.barros

New Member
Hi Steve,
Is it possible to send me what you have sent to Andy? (whose email is madhead @ gmail . com)
antonio.barros @ hagen . pt

Thanx in advance,
Antonio
 

Cringer

ProgressTalk.com Moderator
Staff member
Hi Steve,

if you email me what you want (jdpjamesp AT gmail DOT com), I'll try putting it up here.

Cheers.
 
Top