Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,298,602
Community Members
 
Community Events
165
Community Groups

SQL Server Script for Locating Attachments

Would like query for SQL Server to locate attachments. Was provided the below. Will either of these work for SQL Server?

MYSQL

 selectc.TITLE as "Attachment Name", cp.LONGVAL as "File Size",c2.TITLE as "Page Title", s.SPACENAME as "Space Name", concat("http://<confluence_base_url>/pages/viewpageattachments.action?pageId=", c.PAGEID) as "Location"from CONTENT cjoin CONTENT c2 on c.PAGEID = c2.CONTENTIDjoin CONTENTPROPERTIES cp on c.CONTENTID = cp.CONTENTIDjoin SPACES s on c2.SPACEID = s.SPACEID where c.CONTENTTYPE = 'ATTACHMENT' and cp.PROPERTYNAME = 'FILESIZE'order by cp.LONGVAL desc;

POSTGRESQL

 select c.TITLE as Attachment_Name, cp.LONGVAL as Attachment_Size, s.spacename,c2.TITLE as Page_Title,'http://<confluence_base_url>/pages/viewpageattachments.action?pageId='||c.PAGEID as Locationfrom CONTENT cjoin CONTENT c2 ON c.PAGEID = c2.CONTENTIDjoin CONTENTPROPERTIES cp on c.CONTENTID = cp.CONTENTIDjoin SPACES s on c2.SPACEID = s.SPACEIDwhere c.CONTENTTYPE = 'ATTACHMENT' and cp.PROPERTYNAME = 'FILESIZE'order by cp.LONGVAL desc;

Replace <confluence_base_url> with your Confluence Base URL . This was tested against MySQL and PostgreSQL.

1 answer

0 votes

Hi @Amy Carey 

I believe the query for MySQL should work fine on MS SQL Server.

The only function there is CONCAT which has the same syntax on SQL Server.

Let us know if you get any error when running it.

Kind regards,
Thiago Masutti

Thank you Thiago. We'd like to also add the path and last modified date. How may the query be updated to include that information?

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

An update on Confluence Cloud customer feedback – June 2022

Hi everyone, We’re always looking at how to improve Confluence and customer feedback plays an important role in making sure we're investing in the areas that will bring the most value to the most c...

211 views 1 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you