CodeSmith Sample Scripts

”So, Kramer, what do you think of CodeSmith after using it for a month?”


“I ammmmmmm-LOVIN’ it, Jerry!”


One of the great things about CodeSmith are the many sample .CST scripts.  One I use frequently is the ScriptTableData.cst file to transport a table from development to production.  A sample of the end result (requiring all of, oh, 14 seconds total effort) for a table for quick Query Analyzer duplication to another server would look like the SQL below. 


So the sample scripts alone are worth the effort of checking out CodeSmith.


/*
 * VSS Header, do not delete!
 *
 * $Revision: 1.1 $
 * $Date: 2003/10/05 22:16:53 $
 * $Author: Administrator $
 *
 */


USE myDatabase
GO



–VSS $Revision: 1.1 $
TRUNCATE TABLE [dbo].[list_states]


DBCC CHECKIDENT (‘[dbo].[list_states]’, RESEED, 1)


SET IDENTITY_INSERT [dbo].[list_states] ON


INSERT INTO [dbo].[list_states] (
 [stid],
 [state_abbrev],
 [state_name],
 [cntryid]
)
 SELECT 1, ‘AL’, ‘Alabama’, 1 UNION
 SELECT 2, ‘AK’, ‘Alaska’, 1 UNION
 SELECT 3, ‘AB’, ‘Alberta’, 1 UNION
 SELECT 4, ‘AZ’, ‘Arizona’, 1 UNION
 SELECT 5, ‘AR’, ‘Arkansas’, 1 UNION
 …
 SELECT 64, ‘NR’, ‘Not Recorded’, 1


SET IDENTITY_INSERT [dbo].[list_states] OFF

Article written by

A long time developer, I was an early adopter of Linux in the mid-90's for a few years until I entered corporate environments and worked with Microsoft technologies like ASP, then .NET. In 2008 I released Sueetie, an Online Community Platform built in .NET. In late 2012 I returned to my Linux roots and locked in on Java development. Much of my work is available on GitHub.