Excel SQL

rabso

New Member
Joined
Oct 21, 2010
Messages
36
Hi Guys, im confused and I hope you can spread some light on this.

I have a sql query that runs in sql studio manager, but doesnt run in excel query manager. I have some queries that do and some that dont run in excel. Are there limitations?

Any ideas why?

Richard Baker
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Depending on what driver is being used will determine what SQL commands are available to you. Care to post any of the offending queries that aren't working (it may well not be immediately obvious to any of us why it is failing but it wouldn't hurt)?
 
Upvote 0
Hi Richard, I am using ODBC, this is my query.


Code:
SELECT
P.ProdId AS 'Finishing Prod Id',
I.OCS_ArtworkNb AS 'Proof Nb',
ID.InventSerialId AS 'Proof Serial Nb'
FROM
ProdTable AS P WITH(NOLOCK) INNER JOIN InventTable AS I WITH(NOLOCK)
ON (P.ItemId = I.ItemID AND I.DataAreaId = 001)
OUTER APPLY (SELECT TOP (1) P2.ProdID, P2.InventDimId, P2.DataAreaId
FROM ProdTable AS P2 WITH(NOLOCK)
WHERE I.OCS_ArtworkNb = P2.ItemID
AND P2.DataAreaId = 003
ORDER BY P2.ProdId DESC) AS P2
INNER JOIN InventDim AS ID WITH(NOLOCK)
ON (P2.InventDimId = ID.InventDimID AND P2.DataAreaId = ID.DataAreaId) 
WHERE
P.DataAreaId = 003
AND P.ProdStatus <> 7
AND P.ProdPoolId = 'Finish'
ORDER BY
P.ProdId

I appriciate any help you can offer.
 
Upvote 0
Does it not give you any sort of (useful) error message?

I don't know for sure but I think you need square braces around field names in Excel rather than apostrophes:-
Code:
SELECT
P.ProdId AS [Finishing Prod Id],
I.OCS_ArtworkNb AS [Proof Nb],
ID.InventSerialId AS [Proof Serial Nb]
 
Upvote 0
Ruddles you are a genius, you have just solved an issue I have had for 2 years. It was the braces, thank you so much.

Regards,
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,833
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top