NonProgrammer
NonProgrammer

Reputation: 1387

Run ODBC select statement from Management Studio

We have a linked server connecting to IBM iSeries server. Usually, it is no problem using the linked server. However, I came across a query that I can't run locally on Management studio because it is using IBM functions and grouping capabilities like:

Functions:

Grouping in select statement (at field level), not in group by:

SELECT SUM(BOOKEDAMT('*CONACTIV', GLPDJC.GLDBK, GLPDJC.GLDPJ, GLPDJC.GLDEC1, GLPDJC.GLDRN1, GLPDJC.GLDJB, GLPDJC.GLDGL, GLPDJC.GLDCC, GLPDJC.GLDRN2, GLPDJC.GLDBT, GLPDJC.GLDBE, GLPDJC.GLDBL, 9, ((XCVTDATE(DATE (SUBSTRING({d '2017-06-30' }, 1, 10))))), GLPDJC.GLDEDT))
    ,field2
    ,field3
FROM .....
GROUP BY field2 field3

Question: How do I run this query locally? Is it possible? I am not sure what the query is exactly doing in order to re-write it and make it run-able.

Upvotes: 0

Views: 166

Answers (1)

cgoll
cgoll

Reputation: 181

You could use OPENQUERY to pass the query along to the remote server.

https://learn.microsoft.com/en-us/sql/t-sql/functions/openquery-transact-sql

Upvotes: 2

Related Questions