Monthly Archives: February 2011
Nicely written post extending the MSDN audio CD writing sample to make it actually write CDs.
Once I have implemented this, I will update with feedback.
C# Audio CD Writer for Windows XP – Sichbo Interactive
Using Open Source? Get NuGet. | Tony Sneed’s Blog
Iterating Through Databases on Sql Server
This is a way to find all of the databases matching a particular name on a SQL Server and process something in those databases.
USE master
GO
set ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
— iterate through DBs
DECLARE @DbNames TABLE (
rowNum int identity (1,1),
dbname sysname NOT NULL )
INSERT INTO @DbNames
SELECT name
FROM sys.databases
WHERE state=0 AND user_access=0 and has_dbaccess(name) = 1
AND [name] like ‘NameToMatch%’
ORDER BY [name]
DECLARE @EndCount int;
SELECT @EndCount = count(*) FROM @DbNames
DECLARE @RowCounter int;
SELECT @RowCounter = 1;
DECLARE @DbName varchar(20);
DECLARE @sql varchar(2000);
WHILE (@RowCounter <= @EndCount)
BEGIN
SELECT @DbName = dbname FROM @DbNames WHERE @RowCounter = rowNum;
SELECT @sql =
‘USE ‘ + @DbName — do something here…
EXEC (@sql)
–PRINT @sql
SELECT @RowCounter = @RowCounter + 1
END