开发者

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开发者_如何学Python 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


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


Apparently there is an update trigger with a select statement in it. I disabled the trigger and the query ran instantly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜