The usability of a text box with ‘the Allow Multiple Values’ is very poor. Typically users see the blank box and think something has failed, rather than click into it and start typing. Here’s a better way. Create a standard text box. Users can type a single value into this text box, or type multiple values separated by commas The TSQL below loads the comma separated values into rows of a temp table The SQL query can now join to the multi-row temp table. There’s even an OR clause to allow a blank text box to not filter anything.
Recent Posts
sp_who3
I’ve long been a fan of sp_who2 for identifying blocks on SQL Server, but it’s a bit clunky and there’s a lot of stuff to wade through. Which is why I’ve collated several scripts from around the place and combined them into sp_who3 I’m using a try_cast function which won’t work prior to SQL2012 I believe. Install the stored proc with the code at the bottom. To run it, just type into SSMS: This will return three result sets. The first is filtered version of sp_who2 which will show only those SPIDs which are blocked, as well as the SPIDs which are blocking. The second returns the standard sp_who2 list, The third returns the exact SQL for each SPID, as well as detailed performance and blocking stats, c/- a query from msdn.
SQL Agent – Environment specific workflow
I like to keep my SQL Agent jobs in sync between environments, however not all jobs need to be run in all environments. To handle this, I’ve been using some TSQL to force a failure and end the job at a point. Here’s the overall job Within that, the TSQL for the ‘–Finish here if DEV–‘ step is To control the workflow, I’m setting the on success and on failure as follows:
Controlling Chart axis in SSRS
Had a tricky one today where the business wanted more axes to show on an SSRS report. Seems fair enough, cause as this example shows, a single line is pretty bland. After a bit of reading, I found a few clues over here. The concept is to convert a number to scientific notation, then use the first digit as a multiplier against 10 to the power of the exponent. This generates a nice round number, which is also divisible by 5. Here’s the code, I just pass the range of values on the chart (the calc is also used for the max of the chart), and the function returns an appropriate interval Here’s how my chart looks wtih the interval calcs: But… well that doesn’t look great either, because 600, 1200, 1800… and the maximum isn’t shown. So then the code ‘evolved’ again… End result:
Hiding SSRS folders from users
I’ve been looking into a way to allow users access to content without being able to see content in the SSRS 2016 Portal. This provides a way for developers to re-use shared objects such as Shared Data Sources and Shared Data Sets without confusing the user. The built in functionality to ‘Hide in Tile View’ is not suitable as: the default configuration for all users is to ‘Show hidden items’ there is no known way to overwrite this property for all users the property is overwritten each time you publish A better way to control visibility is via Security, however the built in ‘Browser’ role has too many rights for this need. Part 1 – Create a new SSRS Role Connect to Integration Services through SSMS Once in, expand Security, Roles, then Add Role Add a new role called ‘Reader’, and grant only rights to ‘View Reports’ and ‘View models’ Part 2 – Grant this role to users on folders you want to hide Connect to your SSRS Portal Edit Permissions for the folder that you want to hide Change the Users group to have ‘Reader’ rights rather than ‘Browser’ rights
SQL Server code to pivot Key Value Pairs into fixed Colums
Today’s requirement was to translate 550k rows of product data from a long list of name / value pairs into a wide table with up to 15 name value pairs per product. I tried a few techniques to achieve this, and found SQL Server’s windowing functions to do a pretty good job of building a cross-tab from this flat list.
Seeding an integer sort code into a Data Warehouse from a varchar
I found this a bit of a challenge this morning, and as it’s my first use of windowing functions in SQL Server I thought I’d share. Our requirement was to add a sort code to our dimension tables for various levels. For some reason many of our business keys are varchars, however I really wanted to get sort codes as integers. Here’s the code: This generates three distinct sort keys, one for each level. Quite nifty I reckon. Long term we’ll look to move this stuff into a source system somewhere, but for now, she’s sorted.
Task Factory’s Upsert ‘Go Slow’ button
If you’re using the Upsert component in Task Factory and notice upserts taking 10-20 minutes and would prefer them to take 10-20 seconds, try removing the tick from ‘Enable Identity Insert’.
SSRS Missing Functionality
Just putting this out there cause surely I can’t be the only one missing this… If you install SSRS on SQL Server 2016 Standard Edition, quite a few of the menu items will be missing. Items such as: Mobile Reports KPI Reports Branding The solution.. install SSRS on Enterprise Edition.
Recent Comments