Technical:
Tips, Tricks & Features
Tips, Tricks & Features
I created this blog to keep track of database and reporting tips, tricks, and features. Some of the information on this blog is from other websites. I am re-posting here so the information I have researched will be in a central location. The majority of the information on this blog is related to SQL Server, SSRS, SSIS, SSAS, BIDS, and Report Builder. I hope the information on this blog will be helpful to others and please feel free to share thoughts, ideas, and code.
Friday, January 28, 2022
Tuesday, October 19, 2021
Notepad++ Scripts
Below are scripts that I have found useful when working in Notepad++.
Find Special Characters in a file using Regular expression: [^\x00-\x7F]+
Wednesday, November 28, 2018
Powershell AD Scripts
This script will give you a list of AD groups based on a filter.
get-adgroup -filter{name -like "_*"} -Properties Description | Select Name
View details of a specific user
Get-ADUser -Identity James.Lawyer -Properties *
View All users in an AD Group
Get-ADGroupMember -identity "RS_BusinessFinance" -Recursive | Get-ADUser -Property DisplayName
| Select Name
Get AD Group Details/Properties
Get-ADGroup -Identity RS_ASPRINCIPALS -Properties *
View details of a specific user
Get-ADUser -Identity James.Lawyer -Properties *
View All users in an AD Group
Get-ADGroupMember -identity "RS_BusinessFinance" -Recursive | Get-ADUser -Property DisplayName
| Select Name
Get AD Group Details/Properties
Get-ADGroup -Identity RS_ASPRINCIPALS -Properties *
Monday, September 17, 2018
Using Like in the Where clause on SSRS Reports
In most of my SSRS reports I use IN or = for Parameters, but sometimes you may need to use Like in the where clause. There are a number of ways you can do this, but I am only showing the method I use.
Select * from Test
Where UserName Like '%' + @ParameterName + '%'
Select * from Test
Where UserName Like '%' + @ParameterName + '%'
Friday, August 31, 2018
Conditional Formatting with Expression
The following code can be used in the background property in SSRS for a field to change the color. In this example I am changing the background color of a Totals field based off of another field (School.)
So if the School field = "District" then I want the Total Field to be Yellow, If it equals Secondary then I want it to be Red and Finally if it equals Elementary I want the field to be Blue
1. In Design View for your report, click on the Textbox you want the colors to be used.
2. Find the Background Color under Fill in the Properties.
3. Select the dropdown for background color and choose Expression
4. Use the code below as a starting point for your conditional Formatting.
=Switch(Fields!School.Value = "District", "Yellow", Fields!School.Value = "Secondary", "Red",Fields!School.Value = "Elementary", "Blue")
So if the School field = "District" then I want the Total Field to be Yellow, If it equals Secondary then I want it to be Red and Finally if it equals Elementary I want the field to be Blue
1. In Design View for your report, click on the Textbox you want the colors to be used.
2. Find the Background Color under Fill in the Properties.
3. Select the dropdown for background color and choose Expression
4. Use the code below as a starting point for your conditional Formatting.
=Switch(Fields!School.Value = "District", "Yellow", Fields!School.Value = "Secondary", "Red",Fields!School.Value = "Elementary", "Blue")
Wednesday, August 29, 2018
Export to Excel Without Page Breaks
In SSRS, by default, the Export to Excel option will render a report with Page Breaks into multiple tabs. This is fine if you want to view the data this way, but if you would prefer to have all the data on one tab then you will need to do the following in the design view of the SSRS Report:
1. Click the group object under Row Groups.
2. In the Properties, Click on the Group arrow to expand if the section is not already expanded.
3. Click on the Group arrow on the second line under Group to expand.
4. Click the arrow to expand PageBreak.
5. Select End for BreakLocation
6. Select Expression for Disabled and type the following in the expression: =IIf(Globals!RenderFormat.Name="EXCELOPENXML", True, False)
7. Save and check the report to ensure the fix worked.
Thursday, April 26, 2018
Use EXCEL to create SQL Insert Code
This script can be put into EXCEL to create Insert statements for SQL. This will save a lot of time if you have data in EXCEL that needs to be put into a SQL table.
This looks at 1 column and adds ' around data
="Insert into tmpCourses (Courses) VALUES ("&"'" & A1 & "'"& ");"
This looks at one column adding Text string before the data
="Insert into tmpCourses (Courses) VALUES ("&"'" & A1 & "'"& ");"
This looks at one column adding Text string before the data
="Insert into UserIDs (userid) VALUES ("& "'SCHOOL\"& A2 & "'"& ");"
This script looks at 3 columns
="Insert into Users (userid,first,last) VALUES ("& A2 & ","& CONCATENATE("'",B2,"'") &", "& CONCATENATE("'",C2,"'") &");"
Subscribe to:
Posts (Atom)