Will my Query affect any rows in the DB??

  • Dear All,

    Hope you are doing well. I am really new to SQL and was wondering whether anyone could just quickly confirm something for me.

    I want write an SQL Query that would create an output which I want to export as a csv. I have already created the query which uses SELECT, CASE, FROM and WHERE. I wanted to run this query in the query window of SQL Server Management Studio, take the output on the bottom of the screen, right click and hit export as csv.

    I'm pretty sure it won't affect any rows in the raw database, but before I run it in the actual database, I just wanted to make sure it's safe.

    Here is what the  Query will look like

    SELECT OrderID,

    CASE

    WHEN OrderID = 10248 OR OrderID = 10250 THEN Quantity*-1

    ELSE Quantity

    END AS NewQty

    FROM OrderDetails

    WHERE OrderID <> 10249 AND OrderID <> 10251

    Note I changed the column names etc. to match w3 sql sandbox i.e. https://www.w3schools.com/sql/trymysql.asp?filename=trysql_case I will just change the column names to match the actual SQL server column names before running the query if you guys can confirm that this won't affect any rows or columns.

     

    • This topic was modified 2 years, 3 months ago by  Imrans23.
  • Nothing to worry about. SELECT queries merely read data, they do not update it.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply