Saturday, July 8, 2017

Introduction to GIT and SourceTree



Git is an open source Version Control software to handle from small to very large projects with speed and efficiency. For documentation you can see the "https://git-scm.com/doc" link.



I used "SourceTree" as frontend in my local machine. It's a GUI for GIT and also a free software which you can download from "https://www.sourcetreeapp.com" link. The Graph at the Left give pictorial representation the history of the code. The description shows



The key concepts of GIT are as follows:

Remote Master:
This is main repository where the code is stored.  It has the latest merged code.

Local Master:
A copy of all code from remote master is stored in Local. Every developer has to set this in order to do the development.

Clone:
=> Clone option is to get a local copy from remote repository
=> Sample screenshot shown below





Pull changes from a remote repository (Git)

=> Click on the local branch you want to work or local master to get the latest changes from REMOTE Master.
=> Click on Pull button top.











Commit and push a change (Git)

=> Click on Commit button on top
=> Select to files you want commit
=> Click on Stage option.
=> All the selected files will be moved to Stage


=> Give the comments for Commit and enable "Push changes immediately to -". As shown below.



=> The changes will be saved and pushed to Remote.



Create a branch (Git)

=> Click on Branch button on top
=> Give new branch name as shown below






=> It will be created locally
=> Your changes will be tracked & saved in the newly created branch.





See the link for further details (it also contains creation and push a branch to the remote repository). https://confluence.atlassian.com/get-started-with-sourcetree/commit-and-push-a-change-git-847359114.html





Merge changes from one branch to another (Git)

You can merge the changes from other branches. Please see the link for further details




To setup a repository please see the following link. This explains various scenarios of setting up a repository.







Thursday, June 29, 2017

SQL server - How to see the tables, columns and views




How to see the tables, columns and views from SQL server Database?

This Blog is for SQL beginners. The approach is to use “INFORMATION_SCHEMA” view to fetch list of tables/columns/views. Please see the below details for further details.



1.       To view list of all the tables using below command.

SELECT                 *             FROM                   INFORMATION_SCHEMA.TABLES

 



          SP_HELP "INFORMATION_SCHEMA.COLUMNS"
             




2.      To see list of fields of a table, use “INFORMATION_SCHEMA.COLUMNS” view. You can also use "SP_HELP '<tablename>' ", but the problem I faced with SP_HELP is the data type of few columns are not correct.



SELECT                 *             FROM                   INFORMATION_SCHEMA.COLUMNS
             



SP_HELP "INFORMATION_SCHEMA.COLUMNS"


              



3.      To see list of views, use “INFORMATION_SCHEMA.VIEW” view. You can see view script by using “VIEW_DEFINITION”.



   SELECT                        *             FROM                   INFORMATION_SCHEMA.VIEWS


             



SP_HELP "INFORMATION_SCHEMA.VIEW"

              




  

Please refer below link to understand more about “INFORMATION_SCHEMA” view.



Friday, May 12, 2017

Simple SQL Trips and Tricks (Formatting)

I found simple SQL Tips and Tricks which helped me to make the changes quickly and analyze issues.


  • Always give the database name in the script. It should be at the top of any SQL script file.
USE [DBName]
GO
;
  • Use the [SchemaName]  and [TableName] in your SQL commands with square brackets ("[]") for fields, schema and table. For example
SELECT [Field1] , [Field2], [Field3] FROM  [dbo].[Table1]; 
 UPDATE [dbo].[Table1]     SET [Field1]  = 'NewValue'   WHERE [Field2] = 'Condition';

  • Give Tab space between each word and also align vertically as shown below:
 UPDATE [dbo].[Table1]    SET [Field1]  = 'NewValue'   WHERE [Field2] = 'Condition';
 UPDATE [dbo].[Tab2]       SET [Field2]  = 'New'            WHERE [F1]       = 'Condition2'; 
 UPDATE [dbo].[Tab3]       SET [Field5]  = 'Update Val' WHERE [Fld1]    = 'Condition2';  
Above simple alignment steps help us in changing values horizontally (using Shift + Alt and then up or down arrow).
I used Microsoft SQL Server Management Studio (SQL Server Management Solutions, SQL Server Management Studio Projects).