Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

259
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda