SSRS how to format memo field - sql-server

I'm pulling data from a SQL Server 2008 R2 database and one of the fields is a memo field.
When the data is displayed it comes out in the format DATE/USER/then the message. There is a line break and this repeats. For example:
30/10/2013 11:34 TRACEY : order Created
30/10/2013 11:38 AUTO : order Authorised
30/10/2013 11:40 TRACEY : order Issued
30/10/2013 11:41 TRACEY : order processed
I don't have an control in changing SQL database tables/fields.
I want to be able to format this ugly block of text but really struggling to find a solution - for display in SSRS report. Is there any way I can add a space between each line? Or strip out certain words or complete lines based on some specific parameter?
I just don;t seem to be enable control formatting of memo fields. Any help appreciated.

You can write your own function (in the report' declaration) which will perform the formatting, but this is not the simple task. After this you can call this function and receive a formatted text.
Samples of this you can find in the following articles:
http://technet.microsoft.com/en-us/library/ms156028.aspx
http://technet.microsoft.com/en-us/library/ms155798%28v=sql.100%29.aspx

Related

SQL Server - Displaying >= a different way on a report

I have a user who wants to show quality spec descriptions where the >= shows as an underlined > instead of having the = sign to the right. In SQL server, I cannot find a way to do this and I don't think there is an ASCII code for this. I know this is an obscure one but I thought I would ask the question.
Thanks,
Maria
Here is more information and an image of what is being asked for.
I wrote a SQL stored procedure that is executed by an SSRS report. The grid that is returned from this proc contains a formatted criteria column. The users want to see Less Than Or Equal To as a left carrot underlined. All in one space and not like this <=. In Excel and Word you can do this because you can just use < and then underline it. But in SQL, I can't do this. I cannot add the underline in SSRS because the column is a big long text string and it's variable. I've convinced the users to forget this. I told them that some things they have done in Word and Excel can't be done on this type of automated report. Short of using the ascii character of < and the ascii character for _ and then making sure they are on top of each other by preventing a space seems way too complicated when they can just get used to seeing <= or >= . Let me know if you agree and thanks for the input.
Thanks for the reply to my post.

how to add command for carriage return ssrs to msword

Goal: To print a mailmerge report with one of the cell with 3 persons contact information ( with each person having name, cell, email)
Issue: All the data is junked up as we trying to display contact data in contact column and it is not persisting the carriage returns from procedure or ssrs.
In our application I am sending data from SSRS report and printing reports in MS Word (Mail Merge)
As I am sending data in one of the table a value which is brought from database is long and formatted. But the formatting is not persisting as the data is passed from ssrs to ms word(xml) via common reporting services.
I tried adding vbcrf / tried formatting data result from stored procedure/ tried adding /n/r as a string while sending the data from ssrs to services none of them are working.
The report looks odd because in one cell all the data is clumsy and has no carriage returns where necessary. I can't do this in separate cells since this is relevant to that column alone.
Thanks in advance.
A line break in Microsoft Word is represented by a vertical tab - ASCII 11, Ctrl-K, or escape code \v.

Unable to view json file in SQL grid

I am trying to generate json data through sql queries. I used "For Json Auto" to generate json.
One of the table contains html data with html tags. At the time of retrieving it in json it gives me error like :
TITLE: Microsoft SQL Server Management Studio
Unable to show XML. The following error happened:
Name cannot begin with the '\' character, hexadecimal value 0x5C. Line 1, position 426.
One solution is to increase the number of characters retrieved from the server for XML data. To change this setting, on the Tools menu, click Options.
BUTTONS:
OK
I have already set the XML character limit to unlimited. But still it gives me same error. Any help on this would be thankful.
The only way I was able to get around this was to switch to Results as Text and increase the number of characters per line greatly.

SSRS Format Numeric not summarizing in excel

I need to set a format for a column when the column "KPI" has a value with '%' I need that the value has the format for a percentage otherwise the currency format, so I have something like this:
=IIF(InStr(Fields!KPI.Value,"%")>0,Format(Fields!DIA.Value, "P"),Format(Fields!DIA.Value, "C"))
That expression works properly, but when I try to export that report to excel, that column is not summarizing when I select several columns as you will see in this picture:
As you can see excel is recounting but not summarizing, I have tried formatting each field from SQL Server and with this formula:
=IIF(InStr(Fields!KPI.Value,"%")>0,Format(Fields!DIA.Value, "###.#%"),Format(Fields!DIA.Value, "###,###,###,###.##"))
But the same happend when I export that report to excel, is there another way to handle this?
In order to make sure that Excel interprets a value as numeric, you can use the RenderFormat global variable to detect when the report is being rendered for Excel and not include the problematic formatting characters:
=IIF(InStr(Fields!KPI.Value,"%")>0,Format(Fields!DIA.Value, "###.#%"),IIF(OR(Globals!RenderFormat.Name="EXCELOPENXML",Gl‌​obals!RenderFormat.N‌​ame="EXCEL"),Fields!‌​DIA.Value,Format(Fie‌​lds!DIA.Value, "###,###,###,###.##")))
If its critical that you display a thousands separator in your generated output you can use the Language global variable to detect the user's region and use the appropriate character. That check would take the general form Globals.Lanuage="en-US", depending on what particular regions are involved.
Here's an example of using the RenderFormat.Name variable to check the renderer in VS2013:
When doing a preview of the report, the format will show that the render type is RPL:

SQL 2005 CSV Import Quote Delimited with inner Quotes and Commas

I have a CSV file with quote text delimiters. Most of the 90000 rows are fine, but I have a few rows that have a text field that contains both a quote and a comma. For example the fields value would be:
AB",AB
When Delimited this becomes
"AB"",AB"
When SQL 2005 attempts to import this I get errors such as...
Messages
Error 0xc0202055: Data Flow Task: The column delimiter for column "Column 4" was not found.
(SQL Server Import and Export Wizard)
This only seems to happen when a quote and comma are in a text value together. Values like
AB"AB which becomes "AB""AB"
or
AB,AB which becomes "AB,AB"
work fine.
Here are some example rows...
"1464885","LEVER WM","","B","MP17"
"1465075",":PLT-BC !!NOTE!!","","B",""
"1465076","BRKT-STR MTR !NOTE!","","B",""
"1465172",":BRKT-SW MTG !NOTE!","","B","MP16"
"1465388","BUSS BAR !NOTE!","","B","MP10"
"1465391","PLT-BLKHD ""NOTE""","","B","MP20"
"1465564","SPROCKET:13TEETH,74MM OD,66MM","ID W/.25"" SETSCR","B","MP6"
"S01266330002","CABLE:224"",E122/261,8 CO","","B","MP11"
The last row is an example of the problem - the "", causes the error.
I've had MAJOR problems with SSIS. Things that Access, Excel and even DTS seemed to do very well, SSIS chokes on. Variable record-length data is another problem but, yes, these embedded qualifiers are a major problem. Especially if you do not have access to the import files because they're on someone else's server that you pay to gain access to and might even be 4 to 5 GB in size! Cant just to a "replace all" on that every import.
You may want to check into this at Microsoft Downloads called "UnDouble" and here is another workaround you might try.
Seems like with SSIS in SQL Server 2008, the bug is still there. I dont know why they havent addressed this in the parser but its like we went back in time with SSIS in basic import functionality.
UPDATE 11-18-2010: This bug still exists in SSIS. Amazing.
How about just:
Search/replace all "", with ''; (fix all the broken fields)
Search/replace all ;''; with ,"", (to "unfix" properly empty fields.)
Search/replace all '';''; with "","", (to "unfix" properly empty fields which follow a correct encapsulation of embedded delimiters.)
That converts your original to:
"1464885","LEVER WM","","B","MP17"
"1465075",":PLT-BC !!NOTE!!","","B",""
"1465076","BRKT-STR MTR !NOTE!","","B",""
"1465172",":BRKT-SW MTG !NOTE!","","B","MP16"
"1465388","BUSS BAR !NOTE!","","B","MP10"
"1465391","PLT-BLKHD ""NOTE""","","B","MP20"
"1465564","SPROCKET:13TEETH,74MM OD,66MM","ID W/.25"" SETSCR","B","MP6"
"S01266330002","CABLE:224'';E122/261,8 CO","","B","MP11"
Which seems to run the gauntlet fine in SSIS. You may have to step 3 recursively to account for 3 empty fields in a row ('';'';'';, etc.) but the bottom line here is that when you have embedded text qualifiers, you have to either escape them or replace them. Let this be a lesson in your CSV creation processes going forward.
Microsoft says doubled double quotes inside double quote delimited fields just don't work. A fix is planned for the end of 2011...
In the mean time we will have to use workarounds like described in the other answers.
I would just do a search/replace for ", and replace it with ,
Do you have access to the original file?

Resources