Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSSQL Update Query Displaying Results To Grid

I have an SQL Query that updates IDs in one table based on a join to records in another table. The issue is that for some reason that I do not understand the Update query is actually displaying the results on the query to the grid in SSMS. This is causing an 'Out of Memory Exception' on my machine because it is trying to show 1 million + results in the grid. It is interesting because the query should not display anything except the number of records updated. Any ideas what I am doing wrong?

Here is an example of my query:

UPDATE MyDatabase.dbo.Notes
   SET ParentID = A.ID
  FROM MyDatabase.dbo.Notes N
  JOIN MyDatabase.dbo.Actions A ON N.OldID = A.OldID
 WHERE A.OldID IS NOT NULL
   AND N.OldID IS NOT NULL
   AND N.ParentID IS NULL
like image 870
Matt Avatar asked Nov 05 '22 22:11

Matt


1 Answers

The code listed in your question will not cause any output to the Grid in SSMS by itself

  • Double check that what you pasted is actually your exact query
    • Sometimes extra code can be hiding below the fold
  • Check for triggers on any tables involved
like image 115
Brian Webster Avatar answered Nov 09 '22 14:11

Brian Webster