Deleting records

Results 1 to 2 of 2

Thread: Deleting records

  1. #1
    Join Date
    Dec 1969

    Default Deleting records

    I have an application where i need to have a delete button. I have a list of questions, generated from my DB. Right now i have an edit button which allows me to edit the questions. But i need a delete button too. The only thing is i have the question number displayed for each question and of course the value is in the DB also. How can i delete a record and update the other records question number at the same time? So if i have four questions and delete question 3, question 4 becomes question 3.<BR><BR>

  2. #2
    Join Date
    Dec 1969
    Los Angeles, CA

    Default Easy

    Create Proc @IsntNoWorkCool<BR>(<BR>@QuestionNumber int<BR>)<BR>as<BR>begin<BR>Delete TableName where ColumnName = @QuestionNumber <BR>update TableName set ColumnName = ColumnName -1 where ColumnName &#062; @QuestionNumber <BR>end<BR><BR><BR>oh and you may want to put that in a transaction.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts