CodeSmith 4.0 Beta

In case someone somehow failed to notice, I love CodeSmith.  As such I was thrilled to open my email the other day and encounter an invitation to participate in the CodeSmith 4.0 beta.  It's a closed Beta, so I can't share the binaries, but you can bet that over the next few days I will be sharing my thoughts as I dig into the new version.  That said, here is what the guys at CodeSmith Tools are bragging about in the new version:   CodeSmith Project support (.csp files).  This replaces property sets, the custom tool and the batch format. CodeSmith Projects can be run from the command line, inside MSBuild, inside CodeSmith Studio, and inside Windows Explorer. Inside of Visual Studio, any outputs that are generated will automatically be added to your project. If you build your project and you have the "Generate On Build" option on, your outputs will automatically be re-generated even if you generate from the command line using MSBuild. Progress dialog is shown when running from Windows Explorer. GUI dialogs to easily manage your project file. Easily add new outputs where you select a template and specify the property values. You can also specify merge settings through the GUI to enable code merging support. ActiveSnippet support.  This will allow you to type something like:  "tp Petshop.dbo.Orders" inside of Visual Studio and then hit the expand key (CTRL-E, CTRL-E by default) and it will expand out into a list of property getters/setters and member variables based on the fields and data types of the Orders table. CodeSmith Map support (.csmap files).  This feature will allow you to create dictionary style maps of things like SQL to C# data type mappings. Example: <%@ Map Name="CSharpTypeAlias" Src="System-CSharpAlias.csmap" Description="Maps system types to C# aliases." %> <%= CSharpTypeAlias["System.String"] %> = "string" Ability to reverse the map and use the values as the map keys.  This is useful for doing reverse lookups. Ability to return the key value if a corresponding map entry is not found. Ability to return a default value if a corresponding map entry is not found. Ability to manage maps inside CodeSmith Studio or from Windows Explorer. Ability to manage database schema extended property values from inside of CodeSmith Studio. XmlProperty support has been enhanced to handle more variations of XSD. Template property values are saved for templates so that eachtime you run them, you donb_t have to reset the values manually. .netTiers 2.0 templates are included in the install. Added csxsd.exe to allow manually creating shared XmlPropertyassemblies. Ton of new system extended properties added to SchemaExplorerobjects. Bunch of performance improvements here and there throughoutCodeSmith. Bunch of bug fixes.

BizTalk Learning Resources

I somehow missed this the first time around, but came across a link to it today while doing a Google search.  Luke over at BizTalk Chalk Talk has a great list of online learning resources for BizTalk Server 2006.

Drop All Tables on SQL Server

I've recently been working on getting Community Server installed for another website and had the web installer get a Connection Timeout half way through the database creation.  As such, I was looking for a quick way to scrub a database of all tables (dropping the whole database was not a convenient option).  I looked around a bit on the web and came up with this handy script: IF DB_NAME() IN ('master', 'msdb', 'model', 'distribution')BEGINRAISERROR('Not for use on system databases', 16, 1)GOTO DoneENDSET NOCOUNT ONDECLARE @DropStatement nvarchar(4000)DECLARE @SequenceNumber intDECLARE @LastError intDECLARE @TablesDropped intDECLARE DropStatements CURSOR LOCAL FAST_FORWARD READ_ONLY FOR--viewsSELECT1 AS SequenceNumber,N'DROP VIEW ' +QUOTENAME(TABLE_SCHEMA) +N'.' +QUOTENAME(TABLE_NAME) AS DropStatementFROMINFORMATION_SCHEMA.TABLESWHERETABLE_TYPE = N'VIEW' ANDOBJECTPROPERTY(OBJECT_ID(QUOTENAME(TABLE_SCHEMA) +N'.' +QUOTENAME(TABLE_NAME)),'IsSchemaBound') = 1 ANDOBJECTPROPERTY(OBJECT_ID(QUOTENAME(TABLE_SCHEMA) +N'.' +QUOTENAME(TABLE_NAME)),'IsMSShipped') = 0UNION ALL--procedures and functionsSELECT2 AS SequenceNumber,N'DROP PROCEDURE ' +QUOTENAME(ROUTINE_SCHEMA) +N'.' +QUOTENAME(ROUTINE_NAME) AS DropStatementFROMINFORMATION_SCHEMA.ROUTINESWHEREROUTINE_TYPE = N'FUNCTION' ANDOBJECTPROPERTY(OBJECT_ID(QUOTENAME(ROUTINE_SCHEMA) +N'.' +QUOTENAME(ROUTINE_NAME)),'IsSchemaBound') = 1 ANDOBJECTPROPERTY(OBJECT_ID(QUOTENAME(ROUTINE_SCHEMA) +N'.' +QUOTENAME(ROUTINE_NAME)),'IsMSShipped') = 0UNION ALL--foreign keysSELECT3 AS SequenceNumber,N'ALTER TABLE ' +QUOTENAME(TABLE_SCHEMA) +N'.' +QUOTENAME(TABLE_NAME) +N' DROP CONSTRAINT ' +CONSTRAINT_NAME AS DropStatementFROMINFORMATION_SCHEMA.TABLE_CONSTRAINTSWHERECONSTRAINT_TYPE = N'FOREIGN KEY'UNION ALL--tablesSELECT4 AS SequenceNumber,N'DROP TABLE ' +QUOTENAME(TABLE_SCHEMA) +N'.' +QUOTENAME(TABLE_NAME) AS DropStatementFROMINFORMATION_SCHEMA.TABLESWHERETABLE_TYPE = N'BASE TABLE' ANDOBJECTPROPERTY(OBJECT_ID(QUOTENAME(TABLE_SCHEMA) +N'.' +QUOTENAME(TABLE_NAME)),'IsMSShipped') = 0ORDER BY SequenceNumberOPEN DropStatementsWHILE 1 = 1BEGINFETCH NEXT FROM DropStatements INTO @SequenceNumber, @DropStatementIF @@FETCH_STATUS = -1 BREAKBEGINRAISERROR('%s', 0, 1, @DropStatement) WITH NOWAIT--EXECUTE sp_ExecuteSQL @DropStatementSET @LastError = @@ERRORIF @LastError > 0BEGINRAISERROR('Script terminated due to unexpected error', 16, 1)GOTO DoneENDENDENDCLOSE DropStatementsDEALLOCATE DropStatementsDone:GO