Archive

Archive for March, 2010

Generate insert statements for existing data

March 30, 2010 3 comments

Once in a while I get this query: Do you know any tool to generate scripts for data in an existing table, of course for SQL Server?

Well, There are quite a few options.

If your company is rich enough to sponsor a tool then you could go for Redgate SQLToolBelt. This has quite a nice set of tools to generate scripts from existing data or new data and to compare scripts etc. 

You could also try out the free tool :  http://www.ssmstoolspack.com But this works only with SQL server Management Studio 2005 SP2 or above. 

If you are using SQL Server 2008 you could use the built in option SSMS in 2008. This is a quick run through to generate Insert statements for all of the data in your table, using no scripts or add-ins to SQL Management Studio 2008:

  1. DATABASE NAME: Right Click
  2. TASKS: GENERATE SCRIPTS
  3. Under Table/View Options: Set SCRIPT DATA = TRUE

You will then get the create table statement and all of the INSERT statements for the data straight out of SSMS.

You can also use this simple stored procedure given generously by Vyas.  The procedure that does the script generation is here.

I am using it for quite sometime now. Works perfect for my requirement!

Advertisements

TFS build Sservice account change gives workspace in use error

March 25, 2010 1 comment

When we changed the existing service account we were using for TFS build agent and used a new service account. After this change our continous integration failed with the following error:

Problem:
C:\Program Files\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets(699,5,699,5): error : The working folder [WorkingFolder] is already in use by the workspace [workspace];[domain]\[user] on computer [buildmachine]

Reason:
Part of the Team Build build process involves creating a workspace that can be used to get sources for the build. This workspace is typically deleted and then created during the course of the build, meaning that after the build the workspace hangs around. So – when you changed the service account, the delete for the next build had nothing to do (since workspaces are owned and the current user didn’t have a workspace to delete) and the create failed, since a workspace already existed in the same location. You’ll just need to delete the old workspace, owned by DEV\tfssetup

I found the above excellent tip from the this page.

And the correct command to execute the deletion of workspace is as follows:

C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE>tf workspace /delete /server:http://%5Bservername%5D:8080/ [workspacename];[domainname]\[utcode]

You will need workspace deletion permission to execute the above command.

More information here!

Happy programming!