Posts

Showing posts with the label SQL

Dynamically UNION tables with similar names using SQL

Image
We know it's not a good sign of database design to have multiple tables for the same data, but that's our case here anyway. Suppose we have this database where revenue tables are stored in multiple tables and we want to dynamically union these tables without writing a long select every time. This basically creates a variable that stores the text of the union all select , which gets the name of the tables dynamically from the sys tables then trim the last union all to make sure everything is alright you can print your query before executing it. and here everything seems alright. Replace PRINT with EXEC to execute your query and you are good to go.

Connecting MySQL to Power BI

Image
Connecting MySQL to Power BI Step By Step: Know Your Server's Name and Your Database's Name Connect to your server From server statues, get the name of your server (Host:) From Schemas get your database's name Connect Via Power BI Select Mysql as a Datasource Type your server's name and your database's you can also run a SQL query before importing Select the tables you want to import  Regards.

Import Data From Multiple Excel Files Into One Updatable SQL Server Table Without Coding

Image
It's a sneaky way to get around coding and using visual studio to create a link between a folder and SQL server but it is as efficient as it can be! The main idea is using Power BI's Query Editor to do all the boring work of merging data from multiple excel files for us into one table -also you can wrangle your data however you want- then exporting it using Dax Studio, So let's dig into it. 1- You Will Obviously Have To Download Dax Studio   It is a free 8MBs tool that can be easily downloaded from here:  DAX Studio - The ultimate client tool for working with DAX queries It's easy to install so I'm not gonna explain it to you, sorry. 2- Have A Look On The Data   So this is our data,  It's a folder containing multiple  excel files from which  we want to extract our data and merge it. It can be as many as it is  3- Open The Good Power BI And Get Data 1- Open Power BI 2- Click on 'get data' 3- Select data from 'folder' 4- Select your desired f...