Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

263
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda