Solved

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

Posted on 2013-01-20
3
231 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:murbro
3 Comments
 
LVL 39

Assisted Solution

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

Accepted Solution

by:
käµfm³d   👽 earned 250 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:murbro
ID: 38798204
thanks very much
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
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…

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now