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

Posted on 2013-01-20
Medium Priority
Last Modified: 2013-01-20

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)"
Question by:Murray Brown
LVL 41

Assisted Solution

als315 earned 1000 total points
ID: 38798008
Here you can find sample with variable: TOP (var)
LVL 75

Accepted Solution

käµfm³d   👽 earned 1000 total points
ID: 38798021
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)

Author Closing Comment

by:Murray Brown
ID: 38798204
thanks very much

Featured Post

Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

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.

Join & Write a Comment

One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question