Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2013-01-20
3
Medium Priority
?
239 Views
Last Modified: 2013-01-20
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)"
0
Comment
Question by:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 40

Assisted Solution

by:als315
als315 earned 1000 total points
ID: 38798008
Here you can find sample with variable: TOP (var)
http://msdn.microsoft.com/ru-ru/library/ms189463.aspx
0
 
LVL 75

Accepted Solution

by:
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)
0
 

Author Closing Comment

by:Murray Brown
ID: 38798204
thanks very much
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
Suggested Courses

618 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