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, 10 months ago by  Imrans23.
  • Nothing to worry about. SELECT queries merely read data, they do not update it.

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

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

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