SSRS Report Returning Double Quote string from a Single Quote String

Hi, I'm getting weird thing in resultset from SSRS report when executed. When I pass parameter to a report, which passes String that has single quote value to a split function , it returns rows with double quote. 
For example  following string:
'N gage, Wash 'n Curl,Murray's, Don't-B-Bald
Returns: 
''N gage, Wash ''n Curl,Murray''s, Don''t-B-Bald
through SSRS report.
Here is the split function Im using in a report.
CREATE Function [dbo].[fnSplit] (
@List varchar(8000), 
@Delimiter char(1)
Returns @Temp1 Table (
ItemId int Identity(1, 1) NOT NULL PRIMARY KEY , 
Item varchar(8000) NULL 
As 
Begin 
Declare @item varchar(4000), 
@iPos int 
Set @Delimiter = ISNULL(@Delimiter, ';' ) 
Set @List = RTrim(LTrim(@List)) 
-- check for final delimiter 
If Right( @List, 1 ) <> @Delimiter -- append final delimiter 
Select @List = @List + @Delimiter -- get position of first element 
Select @iPos = Charindex( @Delimiter, @List, 1 ) 
While @iPos > 0 
Begin 
-- get item 
Select @item = LTrim( RTrim( Substring( @List, 1, @iPos -1 ) ) ) 
If @@ERROR <> 0 Break -- remove item form list 
Select @List = Substring( @List, @iPos + 1, Len(@List) - @iPos + 1 ) 
If @@ERROR <> 0 Break -- insert item 
Insert @Temp1 Values( @item ) If @@ERROR <> 0 Break 
-- get position pf next item 
Select @iPos = Charindex( @Delimiter, @List, 1 ) 
If @@ERROR <> 0 Break 
End 
Return 
End
FYI: I'm getting @List value from a table and passing it as a string to split function. 
Any help would be appreciated!
ZK

Another user from TSQL forum posted this code which is returning the same resultset but when I execute both codes in SQL server it works and return single quote as expected.
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/8d5c96f5-c498-4f43-b2fb-284b0e83b205/passing-string-which-has-single-quote-rowvalue-to-a-function-returns-double-quoate?forum=transactsql
CREATE FUNCTION dbo.splitter(@string VARCHAR(MAX), @delim CHAR(1))
RETURNS @result TABLE (id INT IDENTITY, value VARCHAR(MAX))
AS
BEGIN
WHILE CHARINDEX(@delim,@string) > 0
BEGIN
INSERT INTO @result (value) VALUES (LEFT(@string,CHARINDEX(@delim,@string)-1))
SET @string = RIGHT(@string,LEN(@string)-CHARINDEX(@delim,@string))
END
INSERT INTO @result (value) VALUES (@string)
RETURN
END
GO
ZK

Similar Messages

  • SSAS SSRS Report Action on Cell Value w/ Embedded Single Quote Not Executing

    I have configured an SSAS 2008 R2 cube SSRS ReportAction. I'm having problems when the member value for a cell has an embedded single quote, e.g. abc's. The action displays on the context menu appropriately, but when I click on the action, nothing happens.
    For member values that do not have the single quote, the action works as designed. I've added a calculated ember to escape the embedded single quote by adding another single quote, e.g. abc''s, with no luck. Is there a resolution or workaround for this?

    Hi Mdccuber,
    According to your description, you create a reporting action in you cube, and it works fine except the members that have embedded single quote, right? In your scenario, it seems that you pass this value to the report as the parameter.
    In SQL Server Analysis Services (SSAS), when pass values to a report, multi-select parameters have to be placed into IN statement and SQL Server Reporting Services (SSRS) will do single-quote wrapping for string values automatically. In this case, the original
    value that have embedded single quote will be damaged. So this action not work. You can submit a feedback at
    http://connect.microsoft.com/SQLServer/Feedback and hope it is resolved in the next release of service pack or product.
    Regards,
    Charlie Liao
    TechNet Community Support

  • Passing String Which Has Single Quote Row/Value to a Function Returns Double Quoate

    Hi, I'm getting weird thing in resultset. When I pass String which has single quote value in it to a split function , it returns rows with double quote. 
    For example  following string:
    'N gage, Wash 'n Curl,Murray's, Don't-B-Bald
    Returns:
    ''N gage, Wash ''n Curl,Murray''s, Don''t-B-Bald
    Here is the split function:
    CREATE Function [dbo].[fnSplit] (
    @List varchar(8000), 
    @Delimiter char(1)
    Returns @Temp1 Table (
    ItemId int Identity(1, 1) NOT NULL PRIMARY KEY , 
    Item varchar(8000) NULL 
    As 
    Begin 
    Declare @item varchar(4000), 
    @iPos int 
    Set @Delimiter = ISNULL(@Delimiter, ';' ) 
    Set @List = RTrim(LTrim(@List)) 
    -- check for final delimiter 
    If Right( @List, 1 ) <> @Delimiter -- append final delimiter 
    Select @List = @List + @Delimiter -- get position of first element 
    Select @iPos = Charindex( @Delimiter, @List, 1 ) 
    While @iPos > 0 
    Begin 
    -- get item 
    Select @item = LTrim( RTrim( Substring( @List, 1, @iPos -1 ) ) ) 
    If @@ERROR <> 0 Break -- remove item form list 
    Select @List = Substring( @List, @iPos + 1, Len(@List) - @iPos + 1 ) 
    If @@ERROR <> 0 Break -- insert item 
    Insert @Temp1 Values( @item ) If @@ERROR <> 0 Break 
    -- get position pf next item 
    Select @iPos = Charindex( @Delimiter, @List, 1 ) 
    If @@ERROR <> 0 Break 
    End 
    Return 
    End
    FYI: I'm getting @List value from a table and passing it as a string to split function.
    Any help would be appreciated!
    ZK

    fixed the issue by using Replace function like
    Replace(value,'''''','''')
    Big Thanks Patrick Hurst!!!!! :)
    Though I came to another issue which I posted here:
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/a26469cc-f7f7-4fb1-ac1b-b3e9769c6f3c/split-function-unable-to-parse-string-correctly?forum=transactsql
    ZK

  • Pass parameter to ssrs report in performance point webpart from textbox text

    How to pass parameter to ssrs report  in performance point webpart from textbox text
    Please help me to solve this ...
    Bikky Kumar

    Edit your SharePoint page and add new text filter web part.
    Then pass the text filter value to your performance point report using connections. Your report should include at least one parameter to get the value. More over you can set default value in text filter.

  • Reading String within the single quotes

    Hi All,
    Can you please let me know, how to read a String within the sinle quote in line.
    I have to read a report into internal table and again from that I need to read a string within the single quote. Please help me in this.
    Thanks in Advance,
    Raghu

    I have the following code:
    REPORT  test.
    DATA:  v_test(05) TYPE c.
    v_test = ‘TTT’.
    I am getting this errror:
    Field “TTT” is unknown.  It is neither kin on e of the specified tables nor defined by a “DATA” statement.
    For some reason, my single quote is not being recognized from my keyboard.  I noticed that my emotion icons are not being displayed either (example:  I type and i do NOT get the smiley face on my end).
    Is there a button that I pressed that caused that?

  • Output strings from loop into one string

    im trying my best to explain my problem so ber in mind:)
    hey having a bit of trouble with outputing strings from loop
    example
    i typed ab into the textbox
    the output should be 12
    but since it is in a loop it would only output the last string and in this case is 2
    im trying to get both strings from the loop and output strings from loop into one string.
    here is some of my code to understand my problem
    // characters a to f
         char[] charword = {'a','b','c','d','e','f'};
         String charchange ;
      // get text from password textbox
                          stringpassword = passwordTextbox.getText();
                          try {
                          // loop to show password length
                          for ( int i = 0; i < stringpassword.length(); i++ ){
                          // loop to go through alfabet     
                          for (int it = 0; it < charword.length; it++){
                             // if char equals stringwords
                               if (stringpassword.charAt(i) == charword[it]){
                                    System.out.print("it worked");
                                    // change characters start with a
                                    if (charword[it] == 'a'){
                                         charchange = "1";
                                    // change to 2
                                    if (charword[it] == 'b'){
                                         charchange = "2";
                                        }

    Not sure how you are displaying the result but you could display each value as soon as you find it.
    if (charword[it] == 'a'){
        System.out.print("1");
    }If it is in a text field then use append. Or if you really need a String with the entire result then use concatenation.
    if (charword[it] == 'a'){
        charchange += "1";
    }

  • String value changes single quote ' to double quote "

    I am creating a list with different bill codes within single
    quotes as follows
    <cfset corlist = " '1100 ','1200 ','1300 ','1700 ','1800
    ','1950 ','7001 ' ">
    when I do an output
    for
    <cfoutput>AND idbillcode IN ( #corlist
    #)</cfoutput>
    I get the values as follows
    AND idbillcode IN ( '1100 ','1200 ','1300 ','1700 ','1800
    ','1950 ','7001 ')
    However when I put the same string within a cfquery the
    single quotes get replaced by double quotes as follows
    AND idbillcode IN ( ''1100 '',''1200 '',''1300 '',''1700
    '',''1800 '',''1950 '',''7001 '') which throws an error.
    Anybody has any clues.
    Thanks.

    However when I put the same string within a cfquery the
    single quotes
    get replaced by double quotes as follows
    AND idbillcode IN ( ''1100 '',''1200 '',''1300 '',''1700
    '',''1800
    '',''1950
    '',''7001 '') which throws an error.
    Anybody has any clues.
    That is ColdFusion escaping the single quotes, by doubling
    them so that
    you can search for strings such as "singhpk's code does not
    work".
    (Note the single quote/apostrophe that would normally break
    this string
    if it was not escaped.
    To tell CF not to do this, one uses the
    preserveSingleQuotes() function.
    The documentation has all the details.

  • String with embedded single quote

    Hi, all. We're trying to pass a string from one procedure to another, which will then do an EXECUTE IMMEDIATE on it. However, there are single quotes withing the string, and they're driving us nuts! This is what the concatenated string should look like when passed to the pw_execDDL procedure:
    insert into appimmunization.wsrprfs (inoc_id, proof, is_valid,proof_num) values ('MEAG', to_date('02-OCT-05','DD-MMM-YY'), 'Y',1);
    Here's the concatenation process that doesn't work, and there are functions being called within the string:
    chr_sql := 'insert into appimmunization.wsrprfs (inoc_id, proof, is_valid,proof_num) values (' || '''' || prm_inoc_id || '''' || ', ' || 'to_date(' || '''' || prm_proof1 || ''''||','||'''' ||'DD-MMM-YY'||''''||')' || ', ' || '''' || fw_is_proof_valid(prm_birth_date, prm_proof1) || '''' || ',1);';
    pw_execDDL(chr_sql); /* call the procedure to do the EXECUTE IMMEDIATE */
    Help! We've tried every combination -- using two single quotes together, three, and four, and still no luck. Thanks.

    insert into appimmunization.wsrprfs (inoc_id, proof,
    is_valid,proof_num) values ('MEAG',
    to_date('02-OCT-05','DD-MMM-YY'), 'Y',1);
    This statement can be made in a string with the following affectation:
    chr_sql := 'insert into appimmunization.wsrprfs (inoc_id, proof, is_valid,proof_num) values (''MEAG'', to_date(''02-OCT-05'',''DD-MMM-YY''), ''Y'',1)';
    Note please that each single quote in your original string must be specified using two single quotes and that is all. It is more readable and more easy to do it this way.
    Michel.

  • Trouble with inserting a string containing a single quote

    Using php with Oracle
    If I do the following two lines before sending my $Query string through the parse function
    $name = "Dominick's";
    $Query = "INSERT INTO customers (name) values ('$name')";
    it gives me the following error:
    Warning: Ora_Parse failed (ORA-00917: missing comma -- while processing OCI function OPARSE)
    If I try and force the single quote to be surrounded by double quotes and therefore not be confused:
    $name = "Dominick's";
    Query = "INSERT INTO customers (name) values (\"$name\")";
    Trying that yields the following error:
    Warning: Ora_Parse failed (ORA-01741: illegal zero-length identifier -- while processing OCI function OPARSE)
    Help
    Jeff

    If it is possible (and here it is) you should use str_replace instead of ereg_replaceThanks for the reminder about str_replace().
    $Query = "INSERT INTO customers (name) values ('".addSlashes($name)."')";This gives an invalid Oracle SQL statement, which will generally fail with
      ORA-01756: quoted string not properly terminatedFor Oracle, single quotes must be doubled, not escaped with backslash.
    Of the solutions to insert the data, I'd prefer using bind variables
    since no escaping or quote doubling is needed.
    -- CJ

  • String comparison having single quote

    hi
    i m comparing a string which already have a single quote like this
    var_name=khurram' shehzad
    select * from table where name=' var_name ';
    plz help me how to do it bcoz its creating probelm
    thanks and regards,

    Hi,
    I hope the below example will help you.
    SQL>SELECT 'abc''' FROM DUAL WHERE 'abc''' = 'abc''';
    'ABC
    abc'
    1 row selected.
    SQL>
    Regards

  • How to insert a string containing a single quote to the msql database? help

    how can i insert a string which contains a single quote in to database... anyone help
    Message was edited by:
    sijo_james

    Absolutely, Positively use a PreparedStatement. Do not use sqlEscape() function unless you have some overriding need (and I don't know what that could possibly be).
    There are 1000's of posts on the positive aspects of using a PreparedStatement rather than using a Statement. The two primary positive attributes of using a PreparedStatement are automatic escaping of Strings and a stronger security model for your application.

  • Preventing select-string from adding additional undesired strings in the output file

    Hi friends
    in PS 4.0 i am trying to write a function which
    step1: export the list of all eventlogs ----> wevtutil el > "$home\documents\\loglist1.txt"
    step2: deleted the following two lines from loglist1.txt
    DebugChannel
    Microsoft-RMS-MSIPC
    ( the reeson of deleting these two lines is wevtutil cl command, can't clear these two evenlogs among approximately 1000 logs)
    in fact via select-string with -pattern -notmatch parameters, we select anything except these two line
    step3:  pastes the select-string contents into the same file ("$home\documents\loglist1.txt") or into new text file (for example
    "$home\documents\loglist2.txt")
    here is my code:
    function MycleareventsAll {
    cls
    Wevtutil el > "$home\documents\loglist1.txt"
    $mycontents = select-string "$home\documents\loglist1.txt" -pattern DebugChannel, Microsoft-RMS-MSIPC -NotMatch
    cd "$home\documents\"
    $mycontents | out-file loglist2.txt"
    # also i tried ---> $mycontents | set-content "loglist2.txt"# also i tried ---> $mycontents | set-content "loglist1.txt"
    but the problem is, in addition of deletion, unfortunatelly additional strings (filepath, filename, line number) are added into the final text file so wevtutil will fail clearing logs listed in text file.
    here is contents of the final text file
    C:\Users\Administrator\documents\loglist.txt:1:Analytic
    C:\Users\Administrator\documents\loglist.txt:2:Application
    C:\Users\Administrator\documents\loglist.txt:4:DirectShowFilterGraph
    but i need the contents be the same as original file without that two specific line:
    Analytic
    Application
    DirectShowFilterGraph
    i searched but i didn't find a way to prevent select-string cmdlet from adding these edditional strings
    (filepath, filename, line number) into output file while keeping the original contents.
    note: -quiet parameter is not what i want. it removes all contents & simply inserts a true or false.
    any help? 

    don't forget that Guys here know the basics of security such as clearing event logs & ...
    how odd if you don't know this.
    clearing all events is useful in test environment for example when i ma teaching my students & need to see all newly created events & work on them
    Then you are teching your students how not to use an event log.  We use filters and queries to access event logs.  We also use event log CmdLets in PowerShell.  WEVTUTIL is ok but it does not marry wellwith PowerShell as you have seen.
    I have found very few people who are not certified in WIndows administration that know much about eventlogs when it should be a ver important part of administration.  PowerShell has mmade EL management much easier but few take the time to learn how
    to use the EL support in PowerShell.
    I see no point inclearing event logs.  It accomplishes nothing.
    ¯\_(ツ)_/¯
    oh your are introducing me filters & queries in event viewer !! please stop Laughing me this way.
    your problem is you judge about people's knowledge & you persist on your absurd judgments.
    look at your sentence:
    "Then you are teaching your students how not to use an event log" 
    where from you tell this? have you been present in my classes to see what i teach to my students?
    have you seen that i told to my students not to use event viewer?
    my goal of clearing events is related to myself. it's non of your businesses.
    people are not interested to here concurrent irrelevant advises from you like a grandmother. they are searching for a solution. their intent of doing tasks is not up to you.

  • How to open single quote, how to open single quote

    Tried to use single quote marks on keyboard using the apostrophe key but this just places the opening mark comma level how do I do this??  I need to for my uni assignment thanks in advance!!! New MAC user :-)

    What application are you using? In most word processors and page-layout apps, there's the option to turn on "smart quotes"...
    Clinton

  • Split a multiline string from TextEdit into multiple strings

    Hi all,
    I have a small question. I have a string that comes from a multiline TextEdit used for comments. This string has to be split into multiple strings with max 72 chars. The wrapping is set to "hard".
    Can anybody help me on this?
    Thanks
    Francisco

    Hi Francisco,
    this is the complete code I tested, a bit ugly concerning the println etc... (****, not formatting here?):
    package com.btexx;
    import java.util.StringTokenizer;
    import com.sapportals.htmlb.Button;
    import com.sapportals.htmlb.Form;
    import com.sapportals.htmlb.TextEdit;
    import com.sapportals.htmlb.enum.TextWrapping;
    import com.sapportals.htmlb.event.Event;
    import com.sapportals.htmlb.rendering.IPageContext;
    import com.sapportals.htmlb.rendering.PageContextFactory;
    import com.sapportals.portal.prt.component.AbstractPortalComponent;
    import com.sapportals.portal.prt.component.IPortalComponentRequest;
    import com.sapportals.portal.prt.component.IPortalComponentResponse;
    public class TextEditExample extends AbstractPortalComponent
        public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
            IPageContext pageCtx = PageContextFactory.createPageContext(request, response);
            Event lastEvent = pageCtx.getCurrentEvent();
            if (lastEvent == null) {
                Form form = pageCtx.createFormDocument("myFormDocument");
                TextEdit te = new TextEdit("Edit_Text");
                te.setId("TextEditID");
                te.setText("Text to change - or just add text");
                te.setWrapping(TextWrapping.HARD);
                te.setTooltip("Edit and/or add text");
                te.setRows(10);
                te.setCols(72);
                form.addComponent(te);
                Button btn = new Button("MyButton");
                btn.setOnClick("react");
                form.addComponent(btn);
                pageCtx.render();
            } else {
                TextEdit te = (TextEdit) pageCtx.getComponentForId("TextEditID");
                String text = te.getText();
    //            for (int j = 0; j < text.length(); j++) {
    //                System.out.println(text.getBytes()[j] + " - " + text.substring(j, j+1));
                StringTokenizer st = new StringTokenizer(text, "nr");
                String[] texts = new String[st.countTokens()];
                while (st.hasMoreTokens()) {
                    System.out.println("Line : " + st.nextToken());
    I swear, I did not press Return within the TextEdit box, and after that, 13/10 appeared within the text. If just this code does not work the same on your machine, then it seems to be a bug in (your) htmlb (because my P/HF are the most actual, at least they have been yesterday).
    Hope it helps
    Detlev
    Message was edited by: Mark Finnern
    added the [code ] [/code ] (without the blanks)

  • How to fetch the first part of string from a whole lenghty string

    Hi,
    I have a data like - ex1:
      Auto Update : 10/04/2014 08:04  NEW data: xxxx OLD data: yyyy Ack - etr03 : 10/04/2014 08:13
     Auto Update : 10/04/2014 15:24  NEW data1 :xxx  OLD data1: yyyy Auto Update : 10/04/2014 09:36  NEW data1: xxx1 OLD data1: yyy1 Auto Update : 08/04/2014 12:28  NEW data1: xxx2 OLD data1: yyy2 Ack - jmi08 : 10/04/2014 09:53 Ack -
    WWI13 : 10/04/2014 15:32
    I want to compare only NEW data: xxxx OLD data: yyyy or  NEW data1 :xxx  OLD data1: yyyy Auto Update : 10/04/2014 09:36  NEW data1: xxx1 OLD data1: yyy1 Auto Update : 08/04/2014 12:28  NEW data1: xxx2 OLD data1: yyy2with the same ste
    of value from another database but since I used substring I am getting even Ack - etr03 : 10/04/2014 08:13 value whose length changes for above 2 examples.
    USed substring to get NEW data1 :xxx  OLD data1: yyyy Auto Update : 10/04/2014 09:36  NEW data1: xxx1 OLD data1: yyy1 Auto Update : 08/04/2014 12:28  NEW data1: xxx2 OLD data1: yyy2 
    or
    NEW data: xxxx OLD data: yyyy
    but the ack part cannot be removed due to variable lenghts for each data hence could not compare this column between 2 databases. Any help would be highly appreciated.
    Thanks,
    Preetha

    HI ,
    THE INPUT IS
     EX 1:Auto Update : 10/04/2014 15:24  NEW data1 :xxx  OLD data1: yyyy Auto Update : 10/04/2014 09:36  NEW data1: xxx1 OLD data1: yyy1 Auto Update : 08/04/2014 12:28  NEW data1: xxx2 OLD data1: yyy2 Ack - jmi08 : 10/04/2014 09:53
    Ack - WWI13 : 10/04/2014 15:32
    EX 2: Auto Update : 10/04/2014 08:04  NEW data: xxxx OLD data: yyyy Ack - etr03 : 10/04/2014 08:13
    AND THE EXPECTED RESULT IS :
    EX1:NEW data1 :xxx  OLD data1: yyyy Auto Update : 10/04/2014 09:36  NEW data1: xxx1 OLD data1: yyy1 Auto Update : 08/04/2014 12:28  NEW data1: xxx2 OLD data1: yyy2
    EX2 : NEW data: xxxx OLD data: yyyy
    SINCE THE FILED LENGTH CHANGES I WANT TO WRITE A GENRIC QUERY WHICH FETCHES THE ABOVE DATA.I DO NOT WANT TO CREATE ANY TABLE
    Hi Preetha7,
    This make no sense. We cannot guess you database structure. 
    Please post DDL (Create table script)
    and DML (your current query)
    and expected output.
    For more info, please have a look at this thread:
    POSTING TIPS - Code, Images, Hyperlinks, Details
    Thanks!
    sqldevelop.wordpress.com

Maybe you are looking for

  • Itunes 11.1.2 wont download to my windows 7 computer

    I cant get itunes update on windows

  • Mavericks, Photoshop CS6 problem

    Here is a question. I have iMac (27-inch, Late 2009)           iMac - model: iMac11,1           1 2.8 GHz Intel Core i7 CPU: 4 cores           16 GB RAM and           Apple Cinema Display When I have TWO files open in TWO SEPARATE display and use the

  • To display the Product Type 51D

    Hi friends I working on Banking Details report.... I want to retreive the transactions(VTBFHA-RFHA) related to 51D product type(VTBFHA-SGSART)  also ... following is the code given by them ... which are not satisfying to retreive 51D. So please sugge

  • Whats the best way to apply office updates during OSD task sequence with Software Update Agent disabled?

    I am trying to update office via the SCCM 2012 R2 OSD task sequence. I know offline updating only updates the core components in the WIM and I'm trying to figure out how to add office updates as well. I am aware of using powershell to try and kick of

  • Group Policy with different Results

    I have Server2008 and Win 7 and Win8.1 clients I created the GPO in fact my Fellow made the modifications in the default group policy that Deny the USB or any removable media He exempted the Users in GPO's Delegation Tab and and select apply group po