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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:38:04+00:00 2026-05-28T13:38:04+00:00

In my current job, I have to run SQL script once in a while

  • 0

In my current job, I have to run SQL script once in a while to update my database. Mostly they are to update certain records that did not work properly.There is a page functionality to do the same but that is a bit longer route so I do it directly against the database.

I just ran an update query and accidentally updated all of my 30,000+ records. Luckily I was working in my test database.

    //Particular query that I am talking about is this
    update customers set  
    customer_id = 100 // where clause is missing and it will update all records
  1. I was wondering, Is there a way to protect the database against such bulk update, may be a trigger that will half if update is affecting more than 500 records? Is there any way to protect database from accidental ill formatted queries. I am particularly interested in updates though.

  2. Am I doing something really wrong when I use SQL Script directly against my production server. I am new and I need expert advice.

  • 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-28T13:38:05+00:00Added an answer on May 28, 2026 at 1:38 pm

    Looking at your query I assume that your Customers table doesn’t have a Primary Key with Identity turned on for the Customer_Id, having both these set on the table would certainly have stopped that script from completing.

    I would suggest that you wrap your query in a transaction. Initially running the script with a rollback statement testing the output before you call Rollback. If the results are as you expected, replace the rollback with a commit and re-run the query.

    EXAMPLE

    BEGIN TRAN
    
    UPDATE Customer SET Customer_ID = 100
    
    SELECT * FROM Customer
    
    ROLLBACK
    --If results look OK comment out ROLLBACK and comment in the line below
    --COMMIT
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At my current job we have a CMS system that is .NET/SQL Server based.
I have a php script run as a cron job that executes a set
I have a SQL 2005 instance that runs a job that uses a Powershell
I'm using microsoft SQL server management studio 2005 I'm trying to run a job
In my current job I'm building a suite of Perl scripts that depend heavily
I have a quartz job that needs to render a GSP, when I tried:
I have a shared MS Sql 2008 database with my hosting provider and MS
I have a SSIS package that runs on a SQL Server 2005 instance that
I have a cron job on an Ubuntu Hardy VPS that only half works
I have an Oracle database backup file (.dmp) that was created with expdp .

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.