Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

258
Views
Delete after insert in SQL SERVER

Is it possible to delete the row after the time ended? I have a query that going to insert the token then after amount of time, if its not used. The row token will be delete.

Here's how I only created my generator and connect to ajax to sql for now:

function makeid(length) {
  var result = '';
  var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
  var charactersLength = characters.length;
  for (var i = 0; i < length; i++) {
    result += characters.charAt(Math.floor(Math.random() *
      charactersLength));
  }
  return result;
}

const resulting = makeid(10)
console.log(resulting)

I used a javascript function connected to an ajax to insert the token to its owner.

Here's my query:

string command1 = "insert into account_token(email, token) values (@email, @token)";

using(var cmd1 = new SqlCommand(command1, con)) {
  cmd1.Parameters.AddWithValue("@email", email);
  cmd1.Parameters.AddWithValue("@token", token);
  cmd1.CommandTimeout = 60;
  cmd1.ExecuteNonQuery();
  con.Close();
}

so basically the "insert into account_token(email, token) values (@email, @token)" in is:

INSERT INTO account_token(email, token) VALUES ('THE_EMAIL', 'THE_RANDOM_GENERATED_TOKEN')

Is using Date.now() is going to solve my problem? PS: I'am using asp.net c#

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Add Expiretime Column in account_token You could create a SQL Job to run each day and execute a specified stored procedure for delete Expired Tokens

http://technet.microsoft.com/en-us/library/ms190268.aspx

https://www.aspsnippets.com/questions/377071/Delete-record-from-table-every-day-at-specific-time-using-SQL-Server-Job-Scheduler/

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!