Tuesday, November 10, 2009

Displaying data source information in Reporting Services reports using expressions

The following expression is about the best I have come up with:

=DataSources("myDataSource").DataSourceReference & " " & DataSources("myDataSource").Type

This will display:


  • Data source name - probably also "myDataSource" in this example. The full path is provided when the report is run in Report Manager
  • Data source type e.g. "OLEDB-MD" is an Analysis Services data source

Limitations:

  • You can't use expressions referring to data sources in the header or footer. But who wants the data source details displayed in the report body??
  • The data source reference has to be hard coded in every report. I'm not aware of any way to enumerate this to just fetch the first datasource. It would be fantastic if the following worked, but it doesn't:
=DataSources[0].DataSourceReference & " " & DataSources[0].Type

Monday, November 2, 2009

Pausing SQL Server transactional replication without losing queue contents

To Pause:
  1. Open SSMS and connect to the distributor
  2. Disable and Stop the "Distribution clean up: distribution" job
  3. Expand SQL Server Agent, right-click on Jobs, select View Job Categories and choose REPL-Distribution
  4. Disable and Stop all listed jobs
To Continue:
  • Enable and Start all the jobs that were stopped
I have seen countless forum discussions for this topic but no succinct list of steps.

Friday, October 30, 2009

SSIS OLE DB Command error with NOT NULL constrained columns

Symptom:

OLE DB Command fails with the following error reported to the package log:

SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E14. An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E14 Description: "The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. The RPC name is invalid.".

Possible Cause:

The data flow task is experiencing a constraint violation.

For a table ThisTable defined as follows:

ThisTableKey int not null
ThisTableValue varchar(10)

and OLE DB Command data flow task containing the following statement:

update ThisTable set ThisTableValue = 'UpdateVal' where ThisTableKey = ?

where ? has been mapped to a data flow column.

If the data flow column contains a NULL value then the task will fail because of the NOT NULL constraint on the column.

Diagnosis:

This is hard to diagnose in SSMS because the SQL statement above will run fine (and do nothing) when ? is substituted with NULL.

Instead add data viewers to the outputs of the offending OLE DB Command. You should see the following columns at debug time:
  • ErrorCode: -1071607702
  • ErrorColumn: 12345 (this is an example value)
  • ErrorDescription: The data value violated the schema constraint.
Open the package in a text editor and search for 12345. You will find a LineageId recorded against it. Search for the LineageId and you will find the column name (should be ThisTableKey).

Resolution:

Use a Conditional Split task to filter out all NULL values in the data flow column before the OLE DB Command.

Monday, September 21, 2009

SSAS Aggregation Design error

Symptom:

The following error appears when deploying the cube or designing aggregations

The reference to attribute is not valid

Cause:

The partitions file has gotten out of sync with the cube file. Perhaps the cube file got checked back in to source control but the partitions file changes were undone.

Solution Options:

You may be able to hack the partitions file to clean up invalid attribute references.

Then again it may be easier just to roll back and reapply your changes.

Thursday, August 27, 2009

SSAS processing error could be due to proactive caching settings

Symptom:

"Errors in the high-level relational engine. The data source view does not contain a definition for the [object] table or view. The Source property may not have been set."

But the data source view doesn't contain this table.

Possible Cause:

A table has been specified for tracking in the notifications for proactive caching, but isn't available any more for some reason.

Solution Options:
  • Update the table name and location as required
  • Disable proactive caching for the partition

See http://www.mssqltips.com/tip.asp?tip=1563 for more details.

Monday, July 20, 2009

Stupid SSIS variable list bug

  1. Bring up the variable list and start editing the name of the first variable
  2. Click the Name column of the variable list to sort the list
  3. Hit Escape to cancel the edit

The variable name you were editing has now replaced the name of the variable that was top of the list after your sort! Cancelling the edit didn't stop this from happening.

Workaround: remember and reenter the variable name that was overwritten. Bleagh.

Thursday, July 2, 2009

Adding folders to SSMS project

Problem:

Can't create folders in a SQL Server 2005 Management Studio project.

It would be handy to be able to separate scripts into folders. Unfortunately only three default folders are available: Connections, Queries and Miscellaneous

Workaround:

  1. Open the .ssmssqlproj file in a text editor
  2. Copy one of the LogicalFolder tags e.g. Miscellaneous
  3. Replace the Folder Name and Type. Make sure the Type value is different from all of the existing folders
  4. Your new folder(s) should now be available in SSMS
Example insertion:

<LogicalFolder Name="Stored Procedures" Type="4" Sorted="true">
<Items />
</LogicalFolder>