SQL Server 2008 Job error 1204 Lock -


i'm having trouble ancient database have maintain. it's been around ages (no, did not design it, no, it's not possible make changes on it)

it goes this: there 2 tables, "documents" , "versions". documents pretty simple table, primary key, varchar storing document name , user created document.versions has foreign key document belongs to, image field actual document stored (mainly word documents , pdfs), extension, , field keeps version number.

whenever application (an ancient vb6 application) consumes document, new version generated.

every night, job run on database, in order delete versions except 5 latest ones of each document. has been working like, forever.

delete t_ad_versions versionnumber < dbo.maxversion(coddocument)-4 

problem is, eventhough everyday versions table has job running in order discar oldest entries, database reaching alarming size (currently 300+ gb).

in order reduce said size, realized there's no need keep versioning pdf elements. so, commanded apply simple modification:

the job delete older versions of word docs, preserving latest 5 versions. other kind of file, versions except latest 1 deleted. so, changed stored procedure job associated to this:

delete t_ad_versions versionnumber < dbo.maxversion(coddocument)-4  , extension  'do%';  delete t_ad_versions versionnumber < dbo.maxversion(coddocument)  , extension  not 'do%'; 

however, after applying change, following day job history notified following error

"the instance of sql server database engine cannot obtain lock resource @ time. rerun statement when there fewer active users. ask database administrator check lock , memory configuration instance, or check long-running transactions. [sqlstate hy000] (error 1204). step failed."

i'm kinda lost now, ideas?

you can try delete row 100 or number works fast.

declare @rows int set @rows = 1 while @rows > 0 begin delete top (100)  t_ad_versions versionnumber < dbo.maxversion(coddocument)-4 , extension  'do%'; set @rows = @@rowcount end 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -