Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Wont Run, but works fine in MSSQL EM 1

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
Hi,

I have the following command in my access database
Code:
SELECT Prod_Provider, COUNT(1) As Tot FROM dbo_Business_Register WHERE (Adv_MemNo = '" & Forms!contacts.[Membership Number] & "') AND (Ins_Lnk IS NULL) GROUP BY Prod_Provider ORDER BY Tot DESC

But it errors with
too few parametes, expected 1

If I remove the ORDER BY Tot , it works fine, why is this happening.

If I run the exact same query direct in the Enterprise Manager console , it executes fine and gives me my desired results, so why won't MS Access run the query?

Thanks,

1DMF

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
... ORDER BY [!]2[/!] DESC

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I don't understand your highlight with the number 2 PHV?,

Anyway I resolved the problem with
Code:
ORDER BY COUNT(1)

Seems SQL EM accepts the 'Tot' field which is dynamically generated when the query is run but the access doesn't.



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
Seems like you even don't tried my suggestion ...
2 meant the second item in the SELECT list.
 
So you can refer to columns via an index number?

And don't be like that PHV, I didn't try your sugestion because I'd solved it before I saw you reply.

I came back to the thread to say it was OK and I'd solved the problem and that was when I saw your post.



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
you can refer to columns via an index number?
In fact, via the ordinal posotion in the SELECT list.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Cool, I never knew that, that really is handy to know.

Many thanks.
1DMF

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top