Click here to Skip to main content
14,391,726 members
   

Database

 
NewsMessage Closed Pin
28-May-19 6:51
MemberMember 1447108128-May-19 6:51 
QuestionCentOS6.9 (MySql v5.7.22) use mysql C API mysql_real_query cause the memory always growing Pin
normga23-May-19 4:13
Membernormga23-May-19 4:13 
AnswerRe: CentOS6.9 (MySql v5.7.22) use mysql C API mysql_real_query cause the memory always growing Pin
jschell23-May-19 7:41
Memberjschell23-May-19 7:41 
GeneralRe: CentOS6.9 (MySql v5.7.22) use mysql C API mysql_real_query cause the memory always growing Pin
normga23-May-19 10:27
Membernormga23-May-19 10:27 
GeneralRe: CentOS6.9 (MySql v5.7.22) use mysql C API mysql_real_query cause the memory always growing Pin
jschell2-Jun-19 9:25
Memberjschell2-Jun-19 9:25 
QuestionBest way to batchprocess a large update Pin
Jörgen Andersson23-May-19 3:09
professionalJörgen Andersson23-May-19 3:09 
AnswerRe: Best way to batchprocess a large update Pin
Richard Deeming23-May-19 8:38
communityengineerRichard Deeming23-May-19 8:38 
How about something like:
DROP TABLE IF EXISTS #ProcessedIDs;
CREATE TABLE #ProcessedIDs (id int NOT NULL Primary Key);

DECLARE @RC int = 5000;

WHILE @RC = 5000
BEGIN
    UPDATE TOP (5000)
        T
    SET
        ...
    OUTPUT
        inserted.id INTO #ProcessedIDs
    FROM
        Target As T
        INNER JOIN Source As S
        ON S.id = T.id
    WHERE
        Not Exists
        (
            SELECT 1
            FROM #ProcessedIDs As P
            WHERE P.id = T.id
        )
    ;
    
    SET @RC = @@ROWCOUNT;
END;

DROP TABLE IF EXISTS #ProcessedIDs;

NB: The DROP TABLE IF EXISTS syntax is new in SQL Server 2016. If you're using an earlier version, you'll need to use an alternative syntax[^].

The OUTPUT clause should work in SQL Sever 2005 or later.



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

GeneralRe: Best way to batchprocess a large update Pin
Jörgen Andersson23-May-19 8:52
professionalJörgen Andersson23-May-19 8:52 
GeneralRe: Best way to batchprocess a large update Pin
Jörgen Andersson23-May-19 23:08
professionalJörgen Andersson23-May-19 23:08 
GeneralRe: Best way to batchprocess a large update Pin
Richard Deeming24-May-19 1:44
communityengineerRichard Deeming24-May-19 1:44 
GeneralRe: Best way to batchprocess a large update Pin
Jörgen Andersson24-May-19 2:45
professionalJörgen Andersson24-May-19 2:45 
GeneralRe: Best way to batchprocess a large update Pin
Jörgen Andersson27-May-19 0:17
professionalJörgen Andersson27-May-19 0:17 
AnswerRe: Best way to batchprocess a large update Pin
Eddy Vluggen24-May-19 1:04
mveEddy Vluggen24-May-19 1:04 
GeneralRe: Best way to batchprocess a large update Pin
Jörgen Andersson24-May-19 2:24
professionalJörgen Andersson24-May-19 2:24 
AnswerRe: Best way to batchprocess a large update Pin
#realJSOP29-May-19 1:43
mve#realJSOP29-May-19 1:43 
GeneralRe: Best way to batchprocess a large update Pin
Richard Deeming29-May-19 1:52
communityengineerRichard Deeming29-May-19 1:52 
GeneralRe: Best way to batchprocess a large update Pin
#realJSOP29-May-19 2:06
mve#realJSOP29-May-19 2:06 
GeneralRe: Best way to batchprocess a large update Pin
Richard Deeming29-May-19 2:12
communityengineerRichard Deeming29-May-19 2:12 
GeneralRe: Best way to batchprocess a large update Pin
#realJSOP29-May-19 2:20
mve#realJSOP29-May-19 2:20 
GeneralRe: Best way to batchprocess a large update Pin
Jörgen Andersson29-May-19 3:59
professionalJörgen Andersson29-May-19 3:59 
GeneralRe: Best way to batchprocess a large update Pin
#realJSOP29-May-19 6:13
mve#realJSOP29-May-19 6:13 
AnswerRe: Best way to batchprocess a large update Pin
#realJSOP29-May-19 2:14
mve#realJSOP29-May-19 2:14 
GeneralRe: Best way to batchprocess a large update Pin
Jörgen Andersson29-May-19 4:01
professionalJörgen Andersson29-May-19 4:01 
QuestionMongoDB Int Primary Key Pin
Kevin Marois17-May-19 9:41
professionalKevin Marois17-May-19 9:41 
AnswerRe: MongoDB Int Primary Key Pin
jschell18-May-19 8:09
Memberjschell18-May-19 8:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.