Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I would suggest learning the necessary SQL to update the appropriate data in the tables. You can use SELECT statements with ORDER BY clauses to view the data in the order that you wish to view it, and then build a query to update that data.</p> <p>You can use transactions to make sure what your updating is correct as you go (if you are still learning the SQL and don't want to mess up the database).</p> <pre><code>BEGIN TRANSACTION -- starts a transaction ROLLBACK -- stops the transaction and rolls back all changes to the tables COMMIT -- stops the transaction and commits all changes to the tables </code></pre> <p>What are you trying to accomplish/update, maybe we can help you with that?</p> <p><strong>EDIT</strong></p> <p>You mentioned that you wanted to edit some product names that are stored inside of a table. and that this would be a one-time task. I've set up a small demo below that I hope will help guide you towards a solution that may work for your situation. copy and paste this into a SQL Management Studio session.</p> <p>Also if you wanted, you can export your current data to say excel, edit that data in excel, import it as a new temporary table and run a SQL update script to update the original table.</p> <pre><code>/* Products Before Update Products After Update =========================== ============================================= ID ProductName ID ProductName --------------------------- --------------------------------------------- 1 MSFT 1 Microsoft Corp. 2 APPL 2 Apple Inc. 3 Cisco Systems, Inc. 3 Cisco Systems, Inc. 4 IBM 4 International Business Machines Corp. 5 JAVA 5 Sun Microsystems, Inc. 6 ORCL 6 Oracle Corp. */ -- Imagine that this table is a table in your database DECLARE @products TABLE ( ID INT, ProductName VARCHAR(255) ) -- And this table has some product information -- which you are trying to update with new information INSERT @products SELECT 1, 'MSFT' UNION ALL SELECT 2, 'APPL' UNION ALL SELECT 3, 'Cisco Systems, Inc.' UNION ALL SELECT 4, 'IBM' UNION ALL SELECT 5, 'JAVA' UNION ALL SELECT 6, 'ORCL' -- Either build an in-memory temporary table of the product names you wish to update -- Or do a database task to import data from excel into a temporary table in the database DECLARE @products_update TABLE ( ID INT, ProductName VARCHAR(255) ) INSERT @products_update SELECT 1, 'Microsoft Corp.' UNION ALL SELECT 2, 'Apple Inc.' UNION ALL SELECT 4, 'International Business Machines Corp.' UNION ALL SELECT 5, 'Sun Microsystems, Inc.' UNION ALL SELECT 6, 'Oracle Corp.' -- Update the table in the database with the in-memory table -- for demo purposes, we use @products to represent the database table UPDATE p1 SET ProductName = ISNULL(p2.ProductName, p1.ProductName) FROM @products p1 LEFT JOIN @products_update p2 ON p1.ID = p2.ID -- Now your products table has been updated SELECT * FROM @products </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload