Bug reports Found a bug? Post it here please.
Version 4.x > Bug reports > SQL Exception when using Web part - Tag cloud, and changing Select top N documents View modes: 
User avatar
Member
Member
bogdan - 3/27/2009 12:30:36 PM
   
SQL Exception when using Web part - Tag cloud, and changing Select top N documents
I had a Blog page with the Tag cloud web part for Blogs and everything was working OK.
I changed Select top N documents from Empty to 20
And I got the following SQL exception on my web site front end

[DataConnection.ExecuteQuery]: 
Query: SELECT TOP 20 DISTINCT CMS_Tag.TagID, TagName, TagCount
FROM CMS_DocumentTag
JOIN CMS_Tag ON CMS_DocumentTag.TagID = CMS_Tag.TagID
JOIN CMS_TagGroup ON CMS_Tag.TagGroupID = CMS_TagGroup.TagGroupID
WHERE (DocumentID IN
(SELECT DocumentID FROM View_CMS_Tree_Joined
WHERE (((SiteName = N'CommunitySite')
AND (Published = 1)) AND (NodeAliasPath LIKE N'/Blog/%'))
AND (TagGroupName = 'Blogs' AND TagGroupSiteID = 2)))
ORDER BY TagName ASC
: caused exception: Incorrect syntax near the keyword 'DISTINCT'.
Incorrect syntax near ')'.



Regarding this I have 2 questions
1) Instead of SELECT TOP 20 DISTINCT one should write SELECT DISTINCT TOP 20 ... Bad mistake.
2) Why SQL exception is visible on the Front-end UI ??? Do you think it is a good practice ? :)
I would expect exception details to be written to the application log or somewhere else, but not on my Front-end.


User avatar
Kentico Support
Kentico Support
kentico_jurajo - 3/27/2009 2:44:10 PM
   
RE:SQL Exception when using Web part - Tag cloud, and changing Select top N documents
Hi,

1) I was not able to reproduce this issue. Which version of SQL server are you using? It seems that SQL 2000 and 2005 can handle this syntax - I have tried it using these SQL servers.

2) I assume that you are running the site in Visual Studio in debug mode - so the debug is set to true in web.config file - therefore the whole exception is displayed.

Best Regards,
Juraj Ondrus

User avatar
Member
Member
bogdan - 3/30/2009 6:44:06 AM
   
RE:SQL Exception when using Web part - Tag cloud, and changing Select top N documents
Hi,

1)
I'm using MS SQL Express 2005.
But the bug is also reproduced on MS SQL 2005 Developers Edition.

I don't know maybe some compatibility setting of the SQL Server could help me to fix this (I will inform you if I found one :) ),
but I would recommend you to fix the query in the next release, because the MSDN description of the SELECT clause (Transact-SQL) explicitly defines that DISTINCT should go before TOP

ms-help://MS.MSDNQTR.v90.en/tsqlref9/html/dc85caea-54d1-49af-b166-f3aa2f3a93d0.htm

SELECT [ ALL | DISTINCT ]
[TOP expression [PERCENT] [ WITH TIES ] ]
< select_list >



2) OK, it is clear

Bogdan

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 4/1/2009 6:38:18 AM
   
RE:SQL Exception when using Web part - Tag cloud, and changing Select top N documents
Hi,

I would like to ask you to be more specific with the web part configuration in the future. when I am using the default settings, it is working fine. The problem occurs if the site name and alias path is specified.
I am sorry for this inconvenience and also for the delay, but it took longer time to find the "proper" configuration to reproduce the issue.

Best Regards,
Juraj Ondrus