Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8559135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:58:15+00:00 2026-06-11T15:58:15+00:00

I have an application using SQLDependency. I want to display the most recent row

  • 0

I have an application using SQLDependency. I want to display the most recent row inserted into a database table to the user when a new row is inserted.

This works as expected when my query is a simple select statement, but given that I want to display the most recently inserted row, I wrote my query as a SELECT TOP statement. This caused multiple exceptions. Upon review of this question I learned that TOP is not valid with SQLDependency so I will have to find some other solution.

This made me wonder two things:

A) What is the reason for SQLDependency not supporting the TOP expression?

B) The solution I came up with is ordering the results based on id and just displaying the last one. This works fine, but my table has very few rows currently. I’m using a dataset, so I anticipate it slowing down once more rows are inserted – which was why I wanted to limit the query to only the most recent row. Is there a better way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T15:58:16+00:00Added an answer on June 11, 2026 at 3:58 pm

    This article explains how Query Notifications technology leverages the indexed views technology and therefore it has the same restrictions. In order to create an efficient indexed view one has to be able to update the index only from the current update, w/o looking at any other row in the table. If the TOP would be allowed then the million dollar question is: if you delete a row that was in the TOP which row should take its place? Answering this would require to search in the table another row that should be now included in the TOP indexed view, instead of the deleted one. Therefore and indexed views containing TOP (or, for the matter, MAX or MIN which suffer from the very same problem) cannot be maintained efficiently and are not permitted.

    You can detect that a row was inserted by querying COUNT_BIG(*). Once you’re notified that the count has changed, querying for the newly inserted row is trivial. You will also be notified on DELETES (ie. false positives).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application using FeedbackPanel to show the user the results of posting
I have an application using a MySql database which is displaying a paginated list
I have a application using a sqlite DB which is put into an ArrayList.
I have an application using in-app purchase. Apparently, if the user has a jailbroken
I have web application using master pages. I want the login page to be
I have an application using Ruby on Rails where a user will be providing
I have an application using a MongoDB database and am about to add custom
I have an application using QtWebKit. It loads URLs and exports some stats on
We have an application using the IBM Informix driver. Whenever we try to open
I have an application using the Google Maps javscript API and the Infobox plug-in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.