Category: NON SQL

How to Automatically Post to Facebook From WordPress

I was wondering if there are any automatic way of posting my blog post to Facebook directly from WordPress as it gets published. I found several ways, as one of my first google search was pointing to a page- https://blog.hubspot.com/website/automatically-post-facebook-wordpress. Its quite good one and describes few methods. However, I was not still convinced to believe there are no way and surfaced the wordpress menu bars multiple times.

Finally, I managed to get a way to do as below. Not sure if there are any other better way around, I would appreciate if there are any simpler way than this.

Go to “My Sites” -> Tools -> Marketing -> Connections

Another way is to provide “Sharing Buttons” in your blog post. But I feel the above one is quite easy and it works out for me well. I do not think to go for any plugins to do this job, this makes life easier for many bloggers like me.

Looking forward your thoughts and requesting you to share if there are any other better or alternatives.

Some thoughts on working from home and remote work

“Work from Home” – A new IT norm in India. Before I jot down my views here, let me clarify, its my personal views, you may or may not agree to all, but good if you can share your thoughts in the comments section.

So, a new norm, Initially, I was not thinking Indian IT would adopt this so fast we are now for various reasons like intermittent network issues, unavailability of network at remote places and other logistics. But, CORONA the real game changer made it all happen so quickly. I would personally think we travelled at least 5 years ahead than we could have been if the pandemic had not been come into our life. Anyway, few things are positives, but lots of negatives like our normal life has impacted a lot like street shop businesses (one of the major business in India), hospitality, travel etc. A mood of despondency had set in many people. However, am taken aback to see our ability and tenacity to fight back with CORONA as well as the challenges due to that. As we started working from home, we also had lots of changes in our life styles. Now, there are few things, which I wanted to share with you all, very important for all of us, thought its not late yet. Here we go…

1. Our posture is our future
It is important to keep a good posture at work. People tend to take their comfort with different method, sitting on bed, lying down or any other awkward ways. But, it is very important that we should follow the right postures for a long run. Desk ergonomic is important to be followed as this work from home extends to more months.
https://www.computer-posture.co.uk/good-computer-posture/

2. Exercise to live healthy
“Good things come to those who sweat.” – It has everything. You may not be able to go to your regular gym, but make sure you continue your walk.

Here are few suugestions:

Yoga
Squats
Jogging on the spot
Plank
Push ups
Skipping rope

https://thewaryworker.com/work-from-home-exercises/

3. Right food at right time
Being at home, the big negative is our food intake. We work along with family, they would supply lots of food to make us energetic, but be aware, those are not really good for our health. Have food for our thoughts not for body (too much). Try to shift from junk to healthy. Avoid dry snacks/chips etc. Staying hydrated is equally important having food at time.

https://medicalxpress.com/news/2020-04-lockdown-opportunity-food-habits-good.html

4. Shift ear-in headphones to ear-on/over headphones
Important guys, I am a victim of it. Switch immediately from ear-in to ear-on headphones. My doctor advised me to do this shift for everyone including kids. Now, kids have online classes and they spend more time with head phones. If you still use ear-in then change to ear-on ones. The later causes lots of fungal issues in your ears and it will lead to a very bad pain in your ears. So, take swift action!

https://www.hearing-speechcenter.com/ear-pain-earphones/

5. Take leaves and clean leaves around you
Now days, no celebrations/marriage functions etc. So you will have many leaves in credit. I would recommend to take the leaves to spend with your family. I used to go to my backyard with my family and clean the area on those days. Good for health and thoughts. Its always good to stick to the office time as you were in office. We may tend to extend our office hours naturally, but we need to be aware when to close the business hour and involve with rest of the world. 🙂

Hope this helps you also, share your thoughts. Stay home stay healthy!

I’d like to grow my readership. If you enjoyed this blog post, please share it with your friends!

Zoomit – A tool to boost your presentation skills

If you are community player or even you want to present something to someone, you may need to zoom in and zoom out certain area of your presentations to make the audience clear about your key areas. I always find it difficult if I share a screen with someone on explaining things and showing it to them. Power point presentation has an option to zoom-in and zoom-out, however, this cannot be applied for other software like SSMS etc. Today, let us quickly see some of the options that could help us in similar situations.

There is a default option in SSMS to zoom out, however, its applicable for only Query part as below:

If you need something for results or any other area, then there is no default way of achieving in SSMS. To support in such situation, I would like to introduce a tool called Zoomit by Microsoft. You can download the tool from the below link:

https://docs.microsoft.com/en-us/sysinternals/downloads/zoomit

You can explore this tool and share your thoughts. If you are already using any other tools, please share the details, happy to explore and play with it. Looking forward your comments.

I’d like to grow my readership. If you enjoyed this blog post, please share it with your friends!

Windows Power Shell Script to run SQL Files in Folder against SQL Server Database

Problem Statement:-

At times, we may need to run SQL files present in a folder against SQL Server Database. Since there are no built in feature available as of now, here is our try with a powershell script.

Pre-requisites:-

  1. Save the (.bat) Batch script & (.ps1) PS Script in same folder in which all the SQL Files are stored.
  2. The Machine should have the SQL Server instance and Power shell tool.
  3. Ensure the parameters values are verified in (.bat) Batch file

Scenarios Covered:-

i) All key values are handled with parameters
ii) If database not exist it will throw error and comes out of PS
iii) If any script has issues/failed, it will throw error and comes out of PS
iv) If we want to run the sql scripts in subfolder as well, then “Includesubfolders” parameter set to 1
v) Batch file automatically retrieve the root path

PS Script:-

$Scriptpath  = $args[0]
$Server =  $args[1]
$database = $args[2]
$user= $args[3]
$pwd= $args[4]
$Includesubfolders=$args[5]

Function IsDBInstalled([string]$Server, [string]$database)
{

 $t=Invoke-Sqlcmd -ServerInstance $Server -Username  $user -Password  $pwd -Database "master" -Query "select 1 from sys.databases where name='$database'" -OutputSqlErrors $true 
  if (!$t) {
            Write-Host "Failed to connect to [$database] database on [$Server]" -BackgroundColor darkred 
            Write-Error "Failed to connect to [$database] database on [$Server]" -ErrorAction Stop
  } else {
              
            write-host "[$database] Database exists in SQL Server [$Server]" -BackgroundColor blue -ForegroundColor black
  }
}

IsDBInstalled $Server $database

if($Includesubfolders -eq 1) {
$subscripts = Get-ChildItem $Scriptpath -recurse | Where-Object {$_.Extension -eq ".sql"}
foreach ($s in $subscripts)
    {   Write-Host "Running Script : " $s.Name -BackgroundColor green -ForegroundColor darkRed
        $tables=Invoke-Sqlcmd -ServerInstance $Server -Username  $user -Password  $pwd -Database  $database -InputFile $s.FullName -ErrorAction 'Stop' -querytimeout ([int]::MaxValue)
        write-host ($tables | Format-List | Out-String) 
        }
} else {
$scripts = Get-ChildItem $Scriptpath | Where-Object {$_.Extension -eq ".sql"}
foreach ($s in $scripts)
    {   Write-Host "Running Script : " $s.Name -BackgroundColor green -ForegroundColor darkRed
        $tables=Invoke-Sqlcmd -ServerInstance $Server -Username  $user -Password  $pwd -Database  $database -InputFile $s.FullName -ErrorAction 'Stop' -querytimeout ([int]::MaxValue)
        write-host ($tables | Format-List | Out-String) 
        }
}

Batch Script:-

@ECHO ON
SET root=%cd%
SET PSScript=%root%\RunSQLFiles.ps1
SET PowerShellDir=C:\Windows\System32\WindowsPowerShell\v1.0
CD /D "%PowerShellDir%"

SET path=%root%
SET "machine=sqlserversample45"
SET "db=sample"
SET "user=username"
SET "pwd=password"
SET "Includesubfolders=0"

Powershell -ExecutionPolicy Bypass -Command "& '%PSScript%' '%path%' '%machine%' '%db%' '%user%' '%pwd%' '%Includesubfolders%'"

Pause
EXIT /B

Output:-

If Database Not Exists:

If Database Exists:

If Any Script has Error:

If “Includesubfolders” parameters set to “1”

I’d like to grow my readership. If you enjoyed this blog post, please share it with your friends!

Amazon RDS for SQL Server versus SQL Server On Amazon EC2

Its an era of Cloud computing and anywhere you go, people talk about cloud computing and its usages, migration and benefits etc.So, I thought of taking an initiative on understanding how SQL Server is versed with Cloud. I would like to admit the fact that it was a “walk away” for me initially, but its quite interesting and fascinated knowing more about. Not just because its success stories,but also I loved the challenges while assessing different scenarios SQL Server with Cloud computing and its support.

This blog post concentrates on AWS and SQL Server.

Let us quickly understand what is AWS first?

AWS is a cloud computing platform provided by Amazon. It includes Infrastructure as a Service (IaaS), Platform as a service (PaaS) and Software As a Service (SaaS). Its a “pay-as-you-go” computing model that means you can scale your depending on your needs and pay for the service. Again, I do not want to go in detail about AWS since lots of resources available in internet and its just a google search away.

AWS offers a great flexibility to run SQL server with two major options:

1. Amazon Elastic Compute Cloud (EC2)
EC2 is a version of VM in Amazon cloud platform. It provides us a complete control for settings/configuration etc.
2. Amazon Relational Database Service (RDS)
RDS is a fully managed service without much control to the user. Service would take care of maintenance and manageability of service instances. Amazon RDS supports various relational database engines like MySQL, PostgresSQL, MS SQL, Oracle , MongoDB, Maria DB and Amazon Aurora etc.
Amazon Relational Database Service provides many more managed services compared to EC2 as shown in the below picture. Hence, its is more of business drivers that the customer can spend more effort on their data rather than maintenance and manageability of their database or instance.

Features supported by RDS & EC2

Now, its very important for SQL Server Professionals that to understand the supporting features for Amazon RDS and Amazon EC2. A quick reference table is prepared as below (as on 25th Apr 2020). We need to understand this reference may or may not needs changes as Amazon increases its capabilities in future and we may need to compare with the latest at the time.

SQL Server Features Amazon RDS for SQL Server SQL Server on Amazon EC2
Versions Supported SQL 2012/2014/2016/2017 ALL
Editions Supported Express/Wb/Standard/Enterprise
High Availability AWS Managed Self Managed
Encryption TDE , Encrypted Storage
Authentication Windows & SQL
Backups Managed Customized
Maintenance Automatic Self Managed
Monitoring & Management Amazon CloudWatch
CDC Available

The above are the major comparison chart, more detailed information, please refer See Also section.

Assessment & Planning

Since we had seen some of the differences between Amazon RDS & Amazon EC2 services, it is time for us to evaluate which one would be best suited for our application if there is a migration plan exists. We all should be aware the fact that it is NOT definitely a LIFT and SHIFT technique, but needs lots of understanding of your system and careful evaluation of certain things. This is the most time taken phase. I would like to list out few parameters to help in this decision making as below. Please note, it is a very wide topic and we should do a careful evaluation depending on your application/project workloads and other characteristics. I would also suggest to have an evaluation done by an Amazon professional for smooth transition.

1. Conduct an inventory of your SQL Server instances
2. Conduct an inventory of your SQL Server databases
3. Know your current Licensing option
One of the main reasons for cloud migration is cost saving. It can be in terms of Infrastructure cost or human resource cost or maintenance cost etc. License Cost can also be reviewed here as AWS comes with License option by default, so it would be important to verify the current licensing option with your organization and Microsoft that can be further evaluated. “Amazon RDS for SQL Server supports the “License Included” licensing model. You do not need separately purchased Microsoft SQL Server licenses. “License Included” pricing is inclusive of software, underlying hardware resources, and Amazon RDS management capabilities.” Please refer for more details.
4. Understand your HA/DR solutions
5. Performance benchmarks if any /Capacity Planning
(Resource utilization like CPU/Memory/IOPS etc)

6. Data Retention Policy if any
This assessment helps us to reduce the Disk cost and utilization. Say, If we have a database with 10 years of data and as per business rules, we just need ONLY last 5 years data , then it is good to purge or archive the older data before we migrate to AWS. This would reduce the space usage and enables an easy migration from On-Premise to Cloud. This is one of the area where Micorsoft Azure has flexibility using Stretch database feature; Amazon RDS does not support Stretch Databases yet (as on published date of this blog post).
7. Various Migration options

We will cover lot more interesting things in upcoming posts, until then stay tuned, stay safe!

See Also:

https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_SQLServer.html

I’d like to grow my readership. If you enjoyed this blog post, please share it with your friends!