January 18, 2022 at 8:10 pm
Dear All,
Hope you are doing well. I am really new to SQL and was wondering whether anyone could just quickly confirm somethinng 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.
January 18, 2022 at 8:37 pm
No, a select doesn't insert, delete, or update data.
January 19, 2022 at 2:56 am
This was removed by the editor as SPAM
January 19, 2022 at 1:52 pm
As @ratbak says, a SELECT won't affect data in tables. Any given SELECT operation can cause blocking as it uses resources, which can slow down things. However, that's extremely common and shouldn't be a concern. You're right to worry about the data in the database. Keep going on your learning.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
January 20, 2022 at 8:35 pm
Thank you for confirming with me RatBak. appreciate your help
January 20, 2022 at 8:37 pm
Hi Grant, Thank you for your kind words of motivation. Looking forward to expand the learning.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply