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 542973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:30:08+00:00 2026-05-13T10:30:08+00:00

I have limited knowledge of SQL so can someone let me know if my

  • 0

I have limited knowledge of SQL so can someone let me know if my thoughts are correct. I have a table that slowly fills up over time. I need to delete records from the first record to a given point in the table. As the primary key is based on GUIDs I am aware that I can’t do a delete easily because I can’t sort based on GUIDs (this was discussed in a previous thread). Would it be possible to use a cursor to look at the first record in the table and progress through the table deleting records until I get to a certain GUID ? The problem I have is that I need to delete all the records that were put in the table before the one defined by the GUID but I can only delete them if the data of the record is older that a predefined date. I know this is all a bit messy but I’m having to retro fit a solution so a bodgy solution will do for now.

I’m using MS SQL Server 2008

  • 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-05-13T10:30:09+00:00Added an answer on May 13, 2026 at 10:30 am

    First of all, you have to wonder if you really want to use a cursor when you work with any kind of SQL query.

    SQL is set based, so it is very efficient and capable of handling ‘sets’ of data.

    First things first, what is your definition of ‘the first record’ ? How do you determine whether a record comes before another record ?

    I understand that you have a ‘datetime’ column defined in your table ?

    Is it possible to determine the ‘datetime’ of the record that you still want to keep in the table ?

    If so, I think you can simply perform a DELETE on the table with a WHERE clause that makes sure that records that are older then the specified date, are not deleted.

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

Sidebar

Related Questions

My limited SQL knowledge prompted this post! I have a stored procedure that runs
I have been tasked with creating a SQL query (limited knowledge) that will show
I need some help with PHP Class. I have limited knowledge about how it
I have a code. But, due to my limited knowledge. i researched and realised
Excuse my ignorance. My knowledge of regular expressions is extremely limited. I have the
I have a database with limited external connections(up to 5). Because of that reason
I have what (with my limited MYSQL knowledge) is a relatively complex query: $sQuery
I have limited SQL background, basically a small amount of manipulation through HTML and
I have limited knowledge of php and mysql, I am trying to learn it
I have a SQL Server that holds a lot of data. An application, running

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.