Advanced Regular Expression – Groups Name Capture LookAround

Zip Code Regular Expression
I’ve been doing alot of regular expression lately and need some place to put my resources.  Below are some very good links for regular Expressions.
How to validate a valid GUID Value in C#
Password Regex

Python Library Reference


Groups, Name Capture, LookAround, Readability and Maintainability, and Delegates

One of the better website pertaining to Regular Expression
Very Simple example of Named Groups, Backreferences, and Regex.Replace
MSDN Article on Backreferences
Regular Expression Replace in SQL 2005 (via the CLR)
SQL Server 2005 Regular Expressions Make Pattern Matching And Data Extraction Easier
A T-SQL Regular Expression Library for SQL Server 2005
Regular Expression Cheat Sheat

generate insert script sql server

I’m using a backup database to do some testing.  This database already has data in it, but I would Like to add some additional data to it, possibly through a use rinterface and scripts.  If everything works well, I want to add the data that I added to backup database to another database.  I don’t want to have to do an export or Bulk Copy.  It seems like to many steps.  What I would rather have is just an insert statement the would crate the data. 
The following links are for script that generate insert statements:
This one is very simple, but I needed to change nvarchar(…)s to nvarchar(Max).
Here are some more links generate insert script for sql server

SQL Server Cursors With Dynamic SQL

First of all I do not recommend using Dynamic SQL or Cursors in production queries or stored procedures.  But they are a necessary evil sometimes.  When I do administrative queries or sp, dynamic SQL and cursors are very handy.
For example I needed to populate a table from meta data in two different tables.  I need the meta data to figure out what tables are needed to be use as a source for my query.  I have to create dynamic query, because at the time of execurting the stored procedure I don’t know which table and column should be used as the source.   After creating the dynamic SQL statement, I then need to loop through the results and create an insert statement for each record returned from the cursor.  Right now I won’t go into detail of the solution, but the follwowing code example helped alot.

[sourcecode language=”sql”]
EXEC sp_executesql
SELECT name FROM dbo.sysobjects;
OPEN @my_cur’
,N’@my_cur cursor OUTPUT’, @my_cur OUTPUT
NEXT FROM @my_cur