January 2008 Blog Posts

SQL Server 2005 Database Truncations and Me

Hi kids... Here's a hot action script for truncating all the tables in your SQL 2005 db for you.  Please post your comments, changes, etc. and I'll update this throughout: select distinct    t.table_schema + '.' + t.table_name as [table]    , case when tc.constraint_type = 'FOREIGN KEY' then 1 else 2 end as [order]into #master_tblfrom information_schema.tables tinner join information_schema.table_constraints tc on    tc.table_schema = t.table_schema and    tc.table_name = t.table_namewhere t.table_type = 'BASE TABLE'and tc.constraint_type like '% KEY'order by 2alter table #master_tbladd idx bigint identity(1,1)select *into #kfrom #master_tblselect *into #rkfrom #kwhile ((select count(*) from #k) > 0)begin    declare @table varchar(1024)    declare @idx bigint    select top 1        @table = [table]        , @idx = idx    from #k    exec ('alter table ' + @table + ' nocheck constraint all')    delete from #k where idx = @idxenddrop table #kselect *into #tfrom #master_tblwhile ((select count(*) from #t) > 0)begin    declare @tidx bigint    declare @ttable varchar(1024)    select top 1        @tidx = idx        , @ttable = [table]    from #t    order by [order]    begin try        exec('truncate table ' + @ttable)        print @ttable + ' purged'    end try    begin catch        print @ttable + ' could not be purged.'    end catch    delete from #t where idx = @tidxenddrop table #twhile ((select count(*) from #rk) > 0)begin    declare @ktable varchar(1024)    declare @kidx bigint    select top 1        @ktable = [table]        , @kidx = idx    from #rk    exec ('alter table ' + @ktable + ' with check check constraint all')    delete from #rk where idx = @kidxenddrop table #rkdrop table #master_tblCheers...

C#, the GAC, and Me

Greetings, Been playing around with Reflection a bit.  I wanted to determine if any of an assembly's dependencies have been loaded from the GAC or not.  Here's the code snippet for you to play around with: { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em;}.csharpcode...

Blog Tag and Me, by P. Simon Duvall

( this post has been blanked out, due to stupidity...)~zagnut

«January»
SunMonTueWedThuFriSat
303112345
6789101112
13141516171819
20212223242526
272829303112
3456789