SQLCLR – Drop Assembly + Dependancies

Recently I have had the pleasure of working on SQL Server 2008 R2 using the SQLCLR support.

Which I must admit it is quite nice to use, though a couple of things have anoyed me while using… one of which is the user of “DROP ASSEMBLY” and its dependancies…. normally this is not a huge problem but when you are write tests, it is good practice to remove/drop everything before deploying.

Being the sort of person that hates doing repetitively, I thought I would do a quick proc…. so let me introduce you to ‘MegaDrop’… yeah… its a rubbish name and the code is not elegant but it gets the job done..

Enjoy…

CREATE PROCEDURE MegaDrop @assemblyName varchar(max)
AS
    declare @name varchar(max)
    declare @type_desc varchar(max)

    declare mf_getprocs_cursor cursor local for
     SELECT so.name, so.type_desc from sys.objects  so with (nolock)
        JOIN sys.assembly_modules sam with (nolock) on so.object_id = sam.object_id
        JOIN sys.assemblies sa with (nolock) on sam.assembly_id = sa.assembly_id
        WHERE ( sa.name = @assemblyName)

    open mf_getprocs_cursor
    fetch next from mf_getprocs_cursor into @name, @type_desc
    while (@@fetch_status <> -1)
    begin
        if @type_desc = 'CLR_STORED_PROCEDURE'
        begin
            print  'Executing DROP PROC '+@name + ' ('+@assemblyName+')'
            execute ('drop proc '+@name)
        end
   
        if @type_desc = 'AGGREGATE_FUNCTION'
        begin
            print  'Executing DROP AGGREGATE '+@name + ' ('+@assemblyName+')'
            execute ('drop Aggregate '+@name)
        end
   
        if @type_desc = 'CLR_TRIGGER'
        begin
            print  'Executing DROP TRIGGER '+@name + ' ('+@assemblyName+')'
            execute ('drop trigger '+@name)
        end
   
        if @type_desc = 'CLR_SCALAR_FUNCTION'
        begin
            print  'Executing DROP FUNCTION '+@name + ' ('+@assemblyName+')'
            execute ('drop function '+@name)
        end
     fetch next from mf_getprocs_cursor into @name, @type_desc
    end
    close mf_getprocs_cursor
    DEALLOCATE mf_getprocs_cursor    

    declare mf_gettypes_cursor cursor local for
     SELECT so.name from sys.assembly_types  so with (nolock)
        JOIN sys.assemblies sa with (nolock) on so.assembly_id = sa.assembly_id
        WHERE ( sa.name = @assemblyName)

    open mf_gettypes_cursor
    fetch next from mf_gettypes_cursor into @name
    while (@@fetch_status <> -1)
    begin
        print 'Executing DROP TYPE '+@name+' ('+@assemblyName+')'
        execute ('drop type '+@name)
     fetch next from mf_gettypes_cursor into @name
    end
    close mf_gettypes_cursor
    DEALLOCATE mf_gettypes_cursor  
   
    if exists (select name from sys.assemblies where name=@assemblyName)
    begin
        print 'Executing DROP ASSEMBLY ('+@assemblyName+')'
        exec ('drop assembly '+@assemblyName)
    end

Visual COBOL 2010 R3

For the last couple of months I have been working on next release which is cunningly name:

Visual COBOL 2010 R3

Which is surprising since the previous was called Visual COBOL 2010 R2.

If you are using any of products in the PC and want to get a sneaky look at the future of COBOL then please apply for our beta program..

http://www.microfocus.com/promotions/wwtevcbp0110/default.aspx?page=form

Good News!

I just purchased a look online and got the crappiest message in the world… thanks Amazon!

Good News! You saved £0.00 on your purchase

Kindle edition prices differ by country. The price for this Kindle edition is different from the price we originally displayed. This is because you were not signed in when you purchased this item. Since the price in your country was lower than the price originally displayed, we went ahead and completed your purchase.

Extruding Light Painting Out Of iPads

Maria has a new iPad… perhaps I should pinch it and have some fun with it.. just like these chaps have…

Making Future Magic: iPad light painting from Dentsu London on Vimeo.

UK Windows Azure Online Conference–8th October

As someone who is very interested in Windows Azure, I would like to draw your attention to a online conference being run Microsoft…

An online conference: “Microsoft Online Cloud Conference: the TechDays team goes online” has had a date change. In my first post about the conference, I said it was running on the 20th September. Well, the registration site was only created this morning and so to give people enough notice of the registration, the date has been changed. It is now running on the 8th October.

Here are the registration details:

Event ID: 1032459728

Language(s): English.
Product(s):
Windows Azure.

Duration: 300 Minutes
Date/TIme:
08 October 2010 09:30 GMT, London
Registration page here.

reference: http://blogs.msdn.com/b/plankytronixx/archive/2010/09/13/uk-windows-azure-online-conference-date-change-now-8th-october.aspx