Delete records from tbl_Attachment table

SELECT [TestRunId]
,[TestResultId]
,[IterationId]
,[ActionPath]
,[AttachmentId]
,[CreationDate]
,[IsComplete]
,[CompressedLength]
,[UncompressedLength]
,[CompressionType]
,[FileName]
,[Comment]
,[AttachmentType]
,[TmiRunId]

—- DELETE

FROM [Tfs_ecom].[dbo].[tbl_Attachment]
where 1=1
–and convert(char(10), CreationDate, 101) >= ’06/08/2010′
and convert(char(10), CreationDate, 112) <= ‘20101231’

 

Delete records from tbl_AttachmentContent table

SELECT ac.[AttachmentId]
,ac.[OffsetFrom]
,ac.[OffsetTo]
,a.uncompressedlength/1024/1024 ‘Size in MB’
,ac.[CreationDate]
, a.AttachmentId
, convert(int, convert(char(8), ac.CreationDate, 112)) ‘Creation Date’
,a.FileName

— DELETE [Tfs_ecom].[dbo].[tbl_AttachmentContent]

FROM tbl_Attachment a

INNER join [Tfs_ecom].[dbo].[tbl_AttachmentContent] ac

on ac.AttachmentId = a.AttachmentId
–where a.AttachmentId is null
–and convert(int, convert(char(8), ac.CreationDate, 112)) > 20111231
and convert(int, convert(char(8), ac.CreationDate, 112)) <= 20101231

 

References:

Advertisements