Reference: https://blog.sqlauthority.com/2011/06/18/sql-server-selecting-domain-from-email-address/
Category: MSSQL
SQL – Select Closest Locations
This is an older script but still works nicely. Setup: You have a table with medical centers that has the address along with latitude and longitude columns. I used this script with a GPS application that pulled your current location and sent it to a web service to get the…
Azure MSSQL – Server Firewall Rules
Run these commands on the master table. First get the existing rules Based on the above query if there are any rules you need to remove get the name and replace Client with the appropriate name If you need to add an IP rule go to https://www.kittell.net/ip.php and update the…
MSSQL – List Users With Permissions
Sometimes you really just need to know how many users you have on your database, the below script will give a quick report for your database. Note: This script is designed to run on a selected database, you will have to select the database first and then run the script.
MSSQL – Datetime In Local Timezone
This function will get the local time based on the time zone difference from UTC
Microsoft Azure SQL – Create SQL User
In this example I create a Read-Only user but this will work with any access as long as you change the db_datareader access role to what you need In SQL Management Studio open a “New Query” with [master] database Again in SQL Management Studio open a “New Query” with the…
Azure – MSSQL Server Information
Same as MSSQL Server Information but is specific to what will work in Azure
MSSQL – Delta Records
Scenario: You have to tables with similar information and you need to see what is different Say Table1 & Table2 are two sales contact tables and you want to combine the tables See SQLFiddle for the data schema to allow you to test the queries below. In each example it…
Remove Last N Characters From Column
Recently in a project to list all the plugins in a WordPress site with their versions I had accidently added .0 on to various rows in error. This script was very helpful to correct this error Reference: http://stackoverflow.com/questions/10470471/delete-last-n-characters-from-field-in-a-sql-server-database