Wednesday, May 18, 2011

SSRS 2008 incorrect number of TablixCornerCell

I got a "nice" error today , while working on a report converted from SSRS 2005 to SSRS 2008.

Error 1 [rsWrongNumberOfTablixCornerCells] The tablix ‘matrix4’ has an incorrect number of TablixCornerCell. The number of TablixCornerCell within TablixCornerRow at index: 0 must equal the number of levels in the TablixRowHierarchy containing TablixHeaders.

Update , 2012-02-10: I fixed the problem by simply reading carefully the error message. All I did was adding an empty <TablixCornerCell></TablixCornerCell> into the <TablixCornerRow>

Wednesday, May 4, 2011

Sometimes VS 2008 cannot access DataSource file

Today, for the second time since we started using SSRS 2008 I had the following stupid error:
Running a dataset works from VS designed, but when I try to run the report (again, from the VS2008 designer) I get errors (DS couldn't be run)

After little investigation I realize that the problem is in fact that the report cannot be built. I had VS2008 access to RDS file denied. this is not a read-only file, is checked-out, so VS should be able to access the file and change it.
However, VS keeps telling that access to {MyReportsFolder}\bin\Debug\{MyDataSource.rds} is denied
The only way I found to fix this was to delete the folder {MyReportsFolder}\bin and rebuild.

Weird...

Friday, January 14, 2011

Error in SSIS VS2005

Yesterday I had to put some code into SSIS packages.
Being a lazy person, what I usually do is copying one of the existing task ("Execute SQL Task") and changing the name and the code itself. Apparently after installing VS2005 SP1 this was not working anymore.

I had to create every "Execute SQL Task", set the connection, etc....which is not a lot but is slower than what I was used to.

The error message I was receiving while trying to copy was "An error occurred while objects were being copied. SSIS Designer could not serialize the SSIS runtime objects". A fast google search revealed this page and the easy fix by jaegd:

Register the xml parser dlls with the below commands.

regsvr32.exe msxml3.dll
regsvr32.exe msxml6.dll

It really worked and fixed my problem, but lets me wondering why Microsoft didn't fix it and release a SP2 with all this fixes.

Wednesday, October 6, 2010

Find the Last Apparition of a Value in String

Well, indeed, I spent few minutes today trying to find the last apparition of a value in string. All this in a  simple T-SQL query in SQLServer 2005. The reason I wanted this is that I need the last part of a string separated by a known delimiter.
I was having a string like this:
declare @a as nvarchar(50)
set @a = 'ssss$kkkk$ooooo$abcde'

I searched the Internet a bit, but with no success. But after few minutes I remembered a function that I seldom use, the reverse. From here, all was as simple as:
select charindex ('$', reverse('ssss$kkkk$ooooo$abcde') )
and further play with this to get the value I need


Update: Of course, using it to trim out the last part of the string is going to be something like this:
select Substring(@a, 1, Len(@a) - charindex ('$', reverse(@a)))

Wednesday, September 22, 2010

SSRS. Must declare scalar variable @Parameter1

Well, one of the errors in Reporting Services 2005 says:

An error occurred during local processing
An error has occurred during report processing
Query execution failed for data set 'Name of the data set'
Must declare the scalar variable @Parameter1

This can be pretty annoying especially when you know you have the report parameter and it used to work. What happens is that, due to some black magic that I cannot explain, the data source is loosing the list of parameters. So the fix is to either add the parameters one by one or just delete and recreate the data source and everything will work.

Wednesday, September 8, 2010

ROLLUP vs CUBE

Well, that's what happen when you don't carefully read the documentation. I have recently discovered the benefit of the WITH ROLLUP clause in SQLServer 2005, and I thought what it was doing was returning all possible combinations of grouping.
Wrong, that's the WITH CUBE.

Using the WITH ROLLUP I found out that the number of rows returned by my query was dependent on the order of the fields in the group by clause. Funny.

Well, to keep it short, I found this: http://msdn.microsoft.com/en-us/library/ms189305%28SQL.90%29.aspx
because "ROLLUP generates a result set that shows aggregates for a hierarchy of values in the selected columns" we get results depending on this hierarchy.

unlike it, what I needed was the WITH CUBE clause: CUBE generates a result set that shows aggregates for all combinations of values in the selected columns.

Monday, November 9, 2009

Visual Studio vs ReportingService

Today I almost pulled my hair off again (well, what rests of it). I was having a local report that used to work until I added some fields in the stored procedure that was filling it. After wandering and thinking and checking the SP, I found this:

Monday, March 30, 2009

Visual Studio Editor

While working on a web site recently, I used Visual Studio 2008 for a small wizard in ASP.NET.

It was cool at the beginning, but it become really painful when, after a while, I was trying to update the tables on the page. Seems like Visual Studio is creating a lot of stupid style-sheets when you drag the table's rows or columns. Hilarious things, like very height rows of the tables, happen. When you try to resize the row back to it's normal size, no way. The only way I found was to manually edit the ASPX and delete the generated styles. And I'm not the only one having problems with it, a friend whom I am working with reported the same problem.

While I like Visual Studio for it's ease of use and clean interface, I found the way it deals with the wizard to be very...let's say at least uninspired. So, what can be done ?
1) Integrate really often, so if the things get messed up you can come back to a good version.
2) Manually edit the ASPX for small changes. It's much faster than trying to convince VS to work the way you'd expect.

Wednesday, January 14, 2009

Don't get over OVER

So I knew about over but didn't have the opportunity to use it every day. But today, I needed a query that would group the data by two criteria; for each group I have a number and then for each group I need the row with that number to be the MAX in the group by first criteria.

Like this: I have table T with Columns A, B and theNumber and I do a


SELECT A,b, sum(theNumber)
FROM T
GROUP BY A, B



And from this I need the rows with the max sum(theNumber) per A

That resulted into


SELECT A, min(B), theNb FROM (
SELECT A, B, theNb, MAX(theNb) OVER (PARTITION BY A) maxim
FROM (
SELECT A,B, sum(thenumber) as theNb FROM T
WHERE someCondition
GROUP BY A, B) aa
) bb
WHERE theNb= maxim



instead of big subQueries and clumsy code

Thursday, November 13, 2008

Be Discrete

Well, sometimes being discreet is being efficient :)
I recently had to optimize some reports for speed and I found one query that took around 8 seconds.
The query, a pretty simple select was doing

SELECT blah, blah
FROM theTable
WHERE Year <= @Year
AND Year > @Year - 10

What I did was using the ugly, but efficient

SELECT blah, blah
FROM theTable
WHERE Year IN (@Year-9, @Year-8, @Year-7, @Year-6, @Year-5, @Year-4, @Year-3, @Year-2, @Year-1, @Year)


The execution time dropped from 8 seconds to about 900 ms.