Pull Pages data from SQL Query

john martin asked on February 23, 2017 12:57

How I get Page title, page url, page description by using SQL query.

Correct Answer

Peter Mogilnitski answered on February 23, 2017 13:19

All these information is stored in dbo.CMS_Document

select DocumentPageDescription , DocumentPageTitle, DocumentUrlPath 
from CMS_Document where DocumentID = 123

Normally I use this view, it contains tree information and common document information

select DocumentPageDescription , DocumentPageTitle, DocumentUrlPath
from View_CMS_Tree_Joined where DocumentID = 123
1 votesVote for this answer Unmark Correct answer

Recent Answers


john martin answered on February 23, 2017 13:25

Thanks @Peter M, I have tried this by using below query but I didn't find the same results that I found in my CMS admin panel. How I get the exact results? Select * from View_CMS_Tree_Joined where NodeSiteID = 1

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on February 23, 2017 13:44 (last edited on February 23, 2017 14:01)

John, if you have several languages defined on your site - you will get several documents, 1 document per language. For 1 node in the tree you can have a few documents, one per language.

You may have several sites hosted in the same DB Select * from View_CMS_Tree_Joined where NodeSiteID = 1 - means give me all the documents that belong to the site with id =1,

P.S. Ah yes, Page Id in the admin interface and documentId in the DB is the same thing :) Select * from View_CMS_Tree_Joined where DocumentId =81

Image Text

Document ID (Page ID) - is unique, so if use this Page id(DocumentID) from the proeprties screen - you will get the exact document:

Select DocumentPageDescription , DocumentPageTitle, DocumentUrlPath  
from View_CMS_Tree_Joined where DocumentId =81
1 votesVote for this answer Mark as a Correct answer

john martin answered on February 23, 2017 14:07

@Peter M, Thank you so much

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on February 23, 2017 14:35

If you are using versioning and/or workflow, this query will not work because the data which would be stored in the cms_document or your custom page type table may be different than the data which is published. So be very careful going directly to the tables for actual content. You're better off using the API to do so.

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.