Monday, December 05, 2016

AWS fatal error: An error occurred (400) when calling the HeadObject operation: Bad Request

While using AWS and trying to copy a file from a S3 bucket to my EC2 instance ended up with this error message.

Command Used: aws s3 cp s3://mybucketname/myfilename.html /var/www/html/
Error: fatal error: An error occurred (400) when calling the HeadObject operation: Bad Request

The error goes off if we add the region information to the command statement. I am using Asia Pacific (Mumbai) so used ap-south-1 as the region name.

Modified Command:
aws s3 cp s3://mybucketname/myfilename.html /var/www/html/ --region ap-south-1

Friday, November 18, 2016

Is Auto Close Enabled in your SQL Server database?

In SQL Server, one of the Database Properties options is Auto Close. This is an option to be used (auto close = True) if our intention is to shut down cleanly and free the resources once the last user accessing that database exits. If after the last user exits we still want to keep the database alive without shutting down then set auto close as FALSE.

But having this setting enabled in a Production environment will end up with performance issues majority of the times. Why? Because once the DB is closed all cached items (data / procedure cache, execution plans) will be flushed out as well. So it has to work from the scratch again when the next user connects in.

How to know what is it set to?

Option 1: Try this query which will return all databases in that server where Auto Close is set to TRUE.

SELECT [name] AS [DatabaseName] FROM SYS.databases 
WHERE is_auto_close_on = 1

--To change AUTO CLOSE option to FALSE
USE [master]
GO
ALTER DATABASE [TEST] SET AUTO_CLOSE OFF;

Option 2: In SQL Server Management Studio, right-click on the database of interest, click on “Properties”, and choose the “Options” tab to see a dialogue box similar to the one shown below


Change that value to False and click OK.

Best practice is to keep this set to FALSE. Still not convinced? my suggestion would be if you’re not too sure whether this setting is helping you or not then have it set to FALSE and/or seek help from experienced DBAs.

Thursday, November 17, 2016

Creating & Executing SQL Queries in Visual Studio Code

Visual Studio Code is a modern, lightweight (but powerful) source code editor which runs on your desktop and is available for Windows, Mac, and Linux.

A new extension has been announced which would support creating and executing SQL queries from within Visual Studio code editor.

Setting up the environment:

1. Download and install Visual Studio code from here - https://code.visualstudio.com/Download
2. Next you need to install the extension "mssql" on it. Refer the steps here in GitHub  or Microsoft Documentation

As explained in the above link bare minimum these steps should have been completed:

  • Installation of Visual studio code and mssql extension
  • Creating the SQL Server Connection Profile
  • Changing the language of the file to "SQL"

Executing the query:

1. It's simple, just type the query you want and to execute it press "CTRL + SHIFT + e"
2. Results can also be saved as a .csv, .json file

Sample output:


Monday, September 19, 2016

Enable thumbnail preview in Windows 10

By default "Always show icons, never thumbnails" option would be enabled in Windows 10. Just follow these two steps to change that setting.

1. Go to windows explorer and click on "Options"




2. Uncheck the "Always show icons, never thumbnails" option


That's it just click on OK and you should be able to see the thumbnail of images.

Monday, September 12, 2016

To run dex in process, the Gradle daemon needs a larger heap. It currently has approximately 910 MB

Warning / Error: To run dex in process, the Gradle daemon needs a larger heap. It currently has approximately 910 MB

Solution which worked for me:

Android Studio 2.1.* has a feature named Dex In Process. To make use of it we need to update our gradle.properties file and increase the amount of memory allocated to the Gradle Daemon VM to a minimum of 2 GB.

So just added the below line in my project gradle.properties

org.gradle.jvmargs=-Xmx2048m

Friday, August 12, 2016

List all stored procedures which are modified recently in a SQL Server database

In SQL Server Management Studio:

  1. Navigate to your database > Programmability 
  2. Press F7 (or) View > Object Explorer Details
  3. In the Object Explorer Details window right click anywhere on the header row and select "Date Last Modified" field (in case it isn't selected already)




T-SQL Script to achieve the same result:

Option 1:

SELECT
    name,
    create_date,
    modify_date
FROM sys.procedures
WHERE modify_date > '2016-08-09'
ORDER BY modify_date DESC;

Option 2:

SELECT
specific_name,
created,
last_altered
FROM INFORMATION_SCHEMA.ROUTINES
WHERE routine_type = N'PROCEDURE'
and last_altered > '2016-08-09' 
ORDER BY last_altered DESC;

Thursday, May 12, 2016

Transform your fear to success

During my days as an MVP (Microsoft Most Valuable Professional), I used to mentor few juniors from the community. One of them used to be very low on confidence and fear of failure was hurting him more than anything. Recently while cleaning up my mailbox found few of the old emails which I have sent him - cleaned it up a bit and just compiled all those into this article.

Important Life Lessons from Cycling

Over the past two years, I acquired many life lessons from cycling. However, after careful thought, I have decided to share the most significant life lessons I have learned in this article