VB.net Error trying to get top 30 rows of query

Hi

I have an app that allows the user to specify any SQL query and the number of records
to pull through. I got the following error trying to run the top 30 records  of:
Select * From Accounting

Incorrect Syntax near the keyword 'From'

Select Top 11 From (Select * From Accounting)"
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
 
käµfm³d 👽Connect With a Mentor Commented:
Why do you have the subquery? It should suffice to do:

Select Top 11 * From Accounting

Nevertheless, you could correct your existing query as:

Select Top 11 * From (Select * From Accounting)
0
 
als315Connect With a Mentor Commented:
Here you can find sample with variable: TOP (var)
http://msdn.microsoft.com/ru-ru/library/ms189463.aspx
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
thanks very much
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.