Illegal Sql : select b.media_id,a.art_id,a.art_type,b.pub_id, b.pub_mode as pub_original_mode , b.pub_id as pub_main_id,b.pub_main_id as pub_main_original_id,2 pub_mode,b.cat_id,b.pub_insdate,b.pub_pubdate,b.pub_socialmedia,a.ART_AUTHORS, (case when a.art_listtitle is null then a.art_title else a.art_listtitle end) as art_title, (case when a.art_title_seo is null then a.art_title else a.art_title_seo end) as art_title_seo,a.ART_SUBTITLE,a.ART_HEADTITLE,a.art_summary,a.art_include,a.ART_MORE, a.src_id,a.ART_MORE_URL,b.PBT_ID,b.ost_id,b.pub_priority,b.PUB_RATINGAVG,b.pub_ratingsum,b.pub_ratingcount, b.PUB_ALLOWCOMMENT, b.PUB_VIEWSCOUNT, b.PUB_VIEWSCOUNTABSOLUTE, b.PUB_COMMENTSCOUNT, b.pub_updatedate,b.pub_actualexpdate,pubc.media_id as mediacopyid,pubc.cat_id as catcopyid,b.pub_expdate,a.art_update,a.ART_TAG from publication b inner join article a on b.art_id=a.art_id left outer join publication pubc on b.pub_main_id=pubc.pub_id where b.ost_id in (1,10,9) and ( isnull(b.pub_expdate, getDate()+1) >=getDate() and b.pub_pubdate<=getDate() or b.ost_id<>1) and b.pub_main_id is null and b.PUB_VIEWSCOUNT is not null and b.cat_id in (42797,42770,42771,42772,42773,42774,42775,42779,42780,42850,42798,42785,42776,42777,42778) order by b.PUB_VIEWSCOUNT DESC || ERROR DESCRIPTION :Transaction (Process ID 61) was deadlocked on lock | communication buffer resources with another process and has been chosen as the deadlock victim. Rerun the transaction. , -2147467259 Connection : Provider=SQLOLEDB.1;Password=per!pter@$21;Persist Security Info=True;User ID=web;Initial Catalog=real_cont;Data Source=dbeditsql.internal.numatek.netuse.gr;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=SRV-REAL;Use Encryption for Data=False;Tag with column collation when possible=False