June 25, 2013

Step By step Guide to integrate SQL management studio with Subversion

 
If you have worked in .net and migrated to database like me then you will surely miss the free add-ins for subversion (ankhsvn). As more and more companies are moving towards the open source versioning system like subversion, it is really painful that Microsoft SSMS studio doesn't have any add-in for subversion.
 
There is a neat and simple solution available from Redgate but it requires license for each PC so if you are working in a place where purchase decisions are difficult to come by then this solution can be very handy.
 
Required: TortoiseSVN in your local machine and write access to subversion repository
 
Create or Check out an existing solution
                                               
·        Decide and create a working folder in C: (You can use other drives but Avoid Network drives)
<!--[if !supportLists]-->o   <!--[endif]-->Ex.  “C:\Test Project”
·         Create a folder in the Subversion repository 
               
 

<!--[if !supportLists]-->·        Right click on the newly created folder and Integrate it with your work folder using the checkout option
  

Once you checked in, your folder will appear like below
 
 
<!--[if !supportLists]-->                                                 Note: You can also check out an existing solution to your work folder
 
·        Create a project in the SQL management Studio and store the solution into above working directory (c:\testproject

 
 
 
Create External Tools
  Open the external tools window
 
 
 

Create External Tools
  Enter the title, command , Arguments and initial Directory as per the below list

 
 
List of commands and parameters
 
Commit:
 
Title : SVN CommitSollution
Command : C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe
Arguments : /command:commit /path:"$(SolutionDir)"
Intial Directory: $(SolutionDir)
 
CommitFile:
 
Title : SVN Commitfile
Command : C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe
Arguments : /command:commit /path:"$(ItemFileName)$(ItemExt) "
Intial Directory: $(ItemDir)
 
Revision History
 
Title : SVN-RevisionHistoryforItem
Command : C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe
Arguments : /command:log /path:"$(SolutionDir)"
Intial Directory: $(SolutionDir)
 
 
How To use ?
 
Choose the projects and select CommitSollution from your tools
 
 


 
 
It will list out all the solution files. Please choose the new Project(s) which you would like to add.
 
Note: You can use the All button to select all the files automatically
 
 



Commit changes of your files

If you prefer to commit the changes in a single file then “CommitFile” option can be used
<!--[if !supportLists]-->a.       <!--[endif]-->Select the file which has had some change from the last check in
<!--[if !supportLists]-->b.      <!--[endif]-->Only the file which has had any change will appear
 


 

Check the revision History

Another common requirement and advantage of using source control would be comparing it against one of the older versions.
 
In my example I have two versions:
First one I checked in during the initial upload and the upload in the previous step.
In the second version I have added the below query
select * from [dbo].[DimEmployee]” into the sampleQuery
 
If I select the samplequery.sql and select SVN-Revisiohistoryforitem then it will appear as below
 

 
 
You can select the version of your choice and compare it with working copy.
 




Just works like a charm J
 

Thanks to John Rummell on external tools and SSMS
 

5 comments:

  1. There is a blank space in the line in your example for CommitFile.

    /command:commit /path: "$(ItemFileName)$(ItemExt) "

    right after "path:" which causes a Tortoise error when committing in SSMS. Other than that works like a charm, Thanks a LOT!

    ReplyDelete
    Replies
    1. Well spotted and thanks Samuel. Corrected now

      Delete
  2. nice thank you mate :)
    it works.

    ReplyDelete
  3. If you want to have an "Update" command as well, check out SQL Server Management Studio and TortoiseSVN (http://www.jrummell.com/blog/2009/11/sql-server-management-studio-and-tortoisesvn/)

    ReplyDelete