{"id":1107,"date":"2005-08-22T17:14:00","date_gmt":"2005-08-22T22:14:00","guid":{"rendered":"http:\/\/blogs.devhorizon.com\/reza\/?p=1107"},"modified":"2005-08-22T17:14:00","modified_gmt":"2005-08-22T22:14:00","slug":"standard-t-sql-escape-characters-dont-work-in-reporting-services-filtering","status":"publish","type":"post","link":"https:\/\/blogs.devhorizon.com\/reza\/2005\/08\/22\/standard-t-sql-escape-characters-dont-work-in-reporting-services-filtering\/","title":{"rendered":"Standard T-SQL escape characters don\u2019t work in reporting services filtering"},"content":{"rendered":"<p><P class=MsoNormal style=\"MARGIN: 0in 0in 0pt\">If you&#8217;ve ever <B><SPAN style=\"FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial\">filtered<\/SPAN><\/B><SPAN style=\"FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial\"> the data within the report using reporting services GUI, you may have realized that \u201c%\u201d as an escape character (wildcard)&nbsp;won\u2019t work and <\/SPAN>you need to replace it with asterisk(\u201c*\u201d) instead.Let\u2019s say you want to filter a field of the dataset called \u201cFields!Employees_Name.Value\u201d to only contain employees whose first names start with \u201cJo\u201d. Obviously there are two ways to do so:<\/P><br \/>\n<OL style=\"MARGIN-TOP: 0in\" type=1><br \/>\n<LI class=MsoNormal style=\"MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo1; tab-stops: list .5in\">Return the filtered data from the data source and just show it in the report<br \/>\n<LI class=MsoNormal style=\"MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo1; tab-stops: list .5in\">Return the raw (non-filtered) data &nbsp;from the data source and just filter it out either on data source level or the container bound to the data source (In this case&nbsp;a Table)<\/LI><\/OL><br \/>\n<P class=MsoNormal style=\"MARGIN: 0in 0in 0pt\">Well, I usually go for the first option, but there are some cases that your data source is shared between couple of containers in your report and you cannot filter it from the scratch. In these circumstances you got to define custom filters on container you wish to show data in it.If you right click on the table object in the report designer, select properties and choose the \u201cFilter Tab\u201d ,you can define the filters there using different operators ( = ,&lt;&gt;,Like and etc) . In our example we expect something like <\/P><br \/>\n<P class=MsoNormal style=\"MARGIN: 0in 0in 0pt\"><B style=\"mso-bidi-font-weight: normal\"><SPAN style=\"mso-tab-count: 1\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>Expression&nbsp;<SPAN style=\"mso-tab-count: 4\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/SPAN>Operator<SPAN style=\"mso-spacerun: yes\">&nbsp;&nbsp;<\/SPAN><SPAN style=\"mso-tab-count: 2\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>Value<?xml:namespace prefix = o ns = \"urn:schemas-microsoft-com:office:office\" \/><o:p><\/o:p><\/B><\/P><br \/>\n<P class=MsoNormal style=\"MARGIN: 0in 0in 0pt\"><SPAN style=\"mso-spacerun: yes\">&nbsp; <\/SPAN>Fields!Employees_Name.Value<SPAN style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp; <\/SPAN><SPAN style=\"mso-tab-count: 2\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN><SPAN style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp;&nbsp;<\/SPAN>Like <SPAN style=\"mso-tab-count: 2\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN><SPAN style=\"mso-spacerun: yes\">&nbsp;&nbsp; &nbsp;<\/SPAN>Jo%<SPAN style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>(WRONG)<\/P><br \/>\n<P class=MsoNormal style=\"MARGIN: 0in 0in 0pt\">Amazingly this doesn\u2019t work.I don\u2019t understand why the standard T-SQL escape characters are changed in reporting services for Like operator!? , but the right way of doing that is as follow:<\/P><br \/>\n<P class=MsoNormal style=\"MARGIN: 0in 0in 0pt\"><B style=\"mso-bidi-font-weight: normal\"><SPAN style=\"mso-tab-count: 1\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>Expression&nbsp;<SPAN style=\"mso-tab-count: 4\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/SPAN>Operator<SPAN style=\"mso-spacerun: yes\">&nbsp;&nbsp;<\/SPAN><SPAN style=\"mso-tab-count: 2\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>Value<o:p><\/o:p><\/B><\/P><br \/>\n<P class=MsoNormal style=\"MARGIN: 0in 0in 0pt\">Fields!Employees_Name.Value<SPAN style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp; <\/SPAN><SPAN style=\"mso-tab-count: 2\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN><SPAN style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp;&nbsp;<\/SPAN>Like <SPAN style=\"mso-tab-count: 2\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN><SPAN style=\"mso-spacerun: yes\">&nbsp;&nbsp; &nbsp;<\/SPAN>\u201cJo*\u201d<SPAN style=\"mso-spacerun: yes\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN>(RIGHT)<\/P><br \/>\n<P class=MsoNormal style=\"MARGIN: 0in 0in 0pt\">Now the question is what if I want to filter all the names starting with \u201cJo\u201d <B style=\"mso-bidi-font-weight: normal\">OR \u201c<\/B>Te\u201d?.First thing you may do is to add another line, and then you are tapped because GUI by default \u201cAND\u201d the conditions instead of \u201cOR\u201d and the GUI doesn\u2019t let you change \u201cAND\u201d to \u201cOR\u201d, because the operator \u201cLIKE\u201d requires exactly 1 and only 1&nbsp;filter value.If you still want to have a wildcard in both statements, then I guess you cannot do it in that way (you\u2019d better change your data source to return the filtered data), but if you know exactly what you are looking for then there is a workaround which is directly changing the RDL (XML \u2013Formatted) code. You need to use operator \u201cIN\u201d instead of \u201cLike\u201d as follows:<\/P><br \/>\n<P class=MsoNormal style=\"MARGIN: 0in 0in 0pt\"><o:p><FILTERS><FILTERS><FILTERS><FILTERS><FILTERS><FILTERS><FILTERS><FILTERS><FILTERS><FILTERS>&lt;Filters&gt;<BR>&nbsp; &lt;Filter&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp; &lt;FilterExpression&gt;=Fields!Employees_Name.Value&lt;\/FilterExpression&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp; &lt;Operator&gt;In&lt;\/Operator&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp; &lt;FilterValues&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;FilterValue&gt;John&lt;\/FilterValue&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;FilterValue&gt;Johan&lt;\/FilterValue&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;FilterValue&gt;Johnoton&lt;\/FilterValue&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/FilterValues&gt;<BR>&nbsp;&nbsp; &lt;\/Filter&gt;<BR>&lt;\/Filters&gt;<\/o:p><\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;ve ever filtered the data within the report using reporting services GUI, you may have realized that \u201c%\u201d as an escape character (wildcard)&nbsp;won\u2019t work and you need to replace it with asterisk(\u201c*\u201d) instead.Let\u2019s say you want to filter a field of the dataset called \u201cFields!Employees_Name.Value\u201d to only contain employees whose first names start with [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-1107","post","type-post","status-publish","format-standard","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Standard T-SQL escape characters don\u2019t work in reporting services filtering - Reza Alirezaei&#039;s Blog %<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blogs.devhorizon.com\/reza\/2005\/08\/22\/standard-t-sql-escape-characters-dont-work-in-reporting-services-filtering\/\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Reza Alirezaei\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2005\\\/08\\\/22\\\/standard-t-sql-escape-characters-dont-work-in-reporting-services-filtering\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2005\\\/08\\\/22\\\/standard-t-sql-escape-characters-dont-work-in-reporting-services-filtering\\\/\"},\"author\":{\"name\":\"Reza Alirezaei\",\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/#\\\/schema\\\/person\\\/cdbb24d283697a65951cb4a14e474938\"},\"headline\":\"Standard T-SQL escape characters don\u2019t work in reporting services filtering\",\"datePublished\":\"2005-08-22T22:14:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2005\\\/08\\\/22\\\/standard-t-sql-escape-characters-dont-work-in-reporting-services-filtering\\\/\"},\"wordCount\":780,\"commentCount\":0,\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2005\\\/08\\\/22\\\/standard-t-sql-escape-characters-dont-work-in-reporting-services-filtering\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2005\\\/08\\\/22\\\/standard-t-sql-escape-characters-dont-work-in-reporting-services-filtering\\\/\",\"url\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2005\\\/08\\\/22\\\/standard-t-sql-escape-characters-dont-work-in-reporting-services-filtering\\\/\",\"name\":\"Standard T-SQL escape characters don\u2019t work in reporting services filtering - Reza Alirezaei's Blog %\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/#website\"},\"datePublished\":\"2005-08-22T22:14:00+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/#\\\/schema\\\/person\\\/cdbb24d283697a65951cb4a14e474938\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/2005\\\/08\\\/22\\\/standard-t-sql-escape-characters-dont-work-in-reporting-services-filtering\\\/\"]}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/#website\",\"url\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/\",\"name\":\"Reza Alirezaei's Blog\",\"description\":\"Blogging from the field!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/#\\\/schema\\\/person\\\/cdbb24d283697a65951cb4a14e474938\",\"name\":\"Reza Alirezaei\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3ba940d84e0ecb909e62e93df4c56daf0395c7e53c914467ab2ee73124a7d7b6?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3ba940d84e0ecb909e62e93df4c56daf0395c7e53c914467ab2ee73124a7d7b6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3ba940d84e0ecb909e62e93df4c56daf0395c7e53c914467ab2ee73124a7d7b6?s=96&d=mm&r=g\",\"caption\":\"Reza Alirezaei\"},\"url\":\"https:\\\/\\\/blogs.devhorizon.com\\\/reza\\\/author\\\/rezaa\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Standard T-SQL escape characters don\u2019t work in reporting services filtering - Reza Alirezaei's Blog %","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blogs.devhorizon.com\/reza\/2005\/08\/22\/standard-t-sql-escape-characters-dont-work-in-reporting-services-filtering\/","twitter_misc":{"Written by":"Reza Alirezaei","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blogs.devhorizon.com\/reza\/2005\/08\/22\/standard-t-sql-escape-characters-dont-work-in-reporting-services-filtering\/#article","isPartOf":{"@id":"https:\/\/blogs.devhorizon.com\/reza\/2005\/08\/22\/standard-t-sql-escape-characters-dont-work-in-reporting-services-filtering\/"},"author":{"name":"Reza Alirezaei","@id":"https:\/\/blogs.devhorizon.com\/reza\/#\/schema\/person\/cdbb24d283697a65951cb4a14e474938"},"headline":"Standard T-SQL escape characters don\u2019t work in reporting services filtering","datePublished":"2005-08-22T22:14:00+00:00","mainEntityOfPage":{"@id":"https:\/\/blogs.devhorizon.com\/reza\/2005\/08\/22\/standard-t-sql-escape-characters-dont-work-in-reporting-services-filtering\/"},"wordCount":780,"commentCount":0,"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/blogs.devhorizon.com\/reza\/2005\/08\/22\/standard-t-sql-escape-characters-dont-work-in-reporting-services-filtering\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/blogs.devhorizon.com\/reza\/2005\/08\/22\/standard-t-sql-escape-characters-dont-work-in-reporting-services-filtering\/","url":"https:\/\/blogs.devhorizon.com\/reza\/2005\/08\/22\/standard-t-sql-escape-characters-dont-work-in-reporting-services-filtering\/","name":"Standard T-SQL escape characters don\u2019t work in reporting services filtering - Reza Alirezaei's Blog %","isPartOf":{"@id":"https:\/\/blogs.devhorizon.com\/reza\/#website"},"datePublished":"2005-08-22T22:14:00+00:00","author":{"@id":"https:\/\/blogs.devhorizon.com\/reza\/#\/schema\/person\/cdbb24d283697a65951cb4a14e474938"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blogs.devhorizon.com\/reza\/2005\/08\/22\/standard-t-sql-escape-characters-dont-work-in-reporting-services-filtering\/"]}]},{"@type":"WebSite","@id":"https:\/\/blogs.devhorizon.com\/reza\/#website","url":"https:\/\/blogs.devhorizon.com\/reza\/","name":"Reza Alirezaei's Blog","description":"Blogging from the field!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blogs.devhorizon.com\/reza\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/blogs.devhorizon.com\/reza\/#\/schema\/person\/cdbb24d283697a65951cb4a14e474938","name":"Reza Alirezaei","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3ba940d84e0ecb909e62e93df4c56daf0395c7e53c914467ab2ee73124a7d7b6?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3ba940d84e0ecb909e62e93df4c56daf0395c7e53c914467ab2ee73124a7d7b6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3ba940d84e0ecb909e62e93df4c56daf0395c7e53c914467ab2ee73124a7d7b6?s=96&d=mm&r=g","caption":"Reza Alirezaei"},"url":"https:\/\/blogs.devhorizon.com\/reza\/author\/rezaa\/"}]}},"_links":{"self":[{"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/posts\/1107","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/comments?post=1107"}],"version-history":[{"count":0,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/posts\/1107\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/media?parent=1107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/categories?post=1107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.devhorizon.com\/reza\/wp-json\/wp\/v2\/tags?post=1107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}