Skip to content

Instantly share code, notes, and snippets.

View gdzierzon's full-sized avatar

gdzierzon

  • Full Stack Devs
  • Utah
View GitHub Profile
@gdzierzon
gdzierzon / SSRS_Matrix_Color.vb
Created March 5, 2019 23:55
SSRS Code to Alternate Color for columns in Matrix
Dim yearGroup = New System.Collections.Hashtable()
Function GetGroupColor(groupName As String, color1 as string, color2 as string) As String
If yearGroup.ContainsKey(groupName) Then
Return yearGroup(groupName)
End If
Dim color = IIf(yearGroup.Count() Mod 2 = 0, color1, color2)
yearGroup.Add(groupName, color)
-- the following external database with new prices should have ben created before execution of this script
/*
CREATE TABLE tmpProductPrices
(
ProductId int
, Price number(10,2)
)
*/
UPDATE p
@gdzierzon
gdzierzon / database_update_script_idempotent_explicit.sql
Created March 4, 2019 07:19
This update script will always result in the same updated values in the database regardless of how many times it is executed.
UPDATE Product SET Price = 12.95 WHERE ProductId = 1435
UPDATE Product SET Price = 23.70 WHERE ProductId = 1436
UPDATE Product SET Price = 31.95 WHERE ProductId = 1498
...
@gdzierzon
gdzierzon / database_update_script_not-idempotent.sql
Created March 4, 2019 06:59
This is an example of a database update script that is not idempotent.
--this code increases the price of all products
--in the category by 20% each time the script is run
--The result of the script is different each time the script is run.
UPDATE Product
SET Price = Price * 1.2
WHERE CategoryId = 3001