Blog Home  Home RSS 2.0 Atom 1.0 CDF  
Hairy Spider Blog - Monday, September 12, 2005
A web of intrigue
 
 Monday, September 12, 2005

Here's a little snippet of SQL to help resolve collation conflicts. You could use it to analyze all the tables on your SQL server and it will attempt to change the collation of any text fields to the default collation.

In the current state it doesn't actually change anything, it simply returns a table of sql command. I wrote a simple app which will do the sql commands as a batchfile - you can copy and paste the data from the Query into this SqlBatchRunner.

Here's the SQL:

set nocount on



declare @defaultCollation varchar(256)
set @defaultCollation =cast(serverproperty('collation') as varchar(256))


declare @dbName varchar(256)
declare @fieldName varchar(256)
declare @tableName varchar(256)
declare @fieldType varchar(256)
declare @fieldSize varchar(10)
declare @sql nvarchar(1000)

declare c cursor for
select name
from master..sysdatabases
    where name in ('tennis', 'prods', 'media')

open c
create table #fields (tableName varchar(256),
    fieldname varchar(256),
    databaseName varchar(256),
    collation varchar(256),
    fieldSize varchar(10),
    fieldTypeName varchar(256))

fetch next from c into @dbName

while @@Fetch_status =0
begin
set @sql = 'insert into #fields select so.Name as tableName, sc.name as fieldname, ''' + @dbName + ''' as DatabaseName, sc.collation, sc.length, st.name as fieldName
            from '
+ @dbName + '..syscolumns sc inner join ' + @dbName + '..sysobjects so
                on so.id = sc.id
                inner join '
+ @dbName + '..systypes st on sc.xtype = st.xtype
            where sc.xtype in (175, 239, 99, 231, 35, 167)
             and so.xtype like ''U''
             and sc.collation not like '''
+ @defaultCollation + '''
             and (select count(*) from '
+ @dbName + '..sysindexkeys where colid = sc.colid) =0
                
                '

                

exec sp_ExecuteSql @sql

fetch next from c into @dbName

end

close c

deallocate c


create table #SqlCommands (sql nvarchar(1000), result int)


declare d cursor for

select tableName, fieldName, databaseName, fieldTypeName, str(fieldSize) from #fields

open d

fetch next from d into @tableName, @fieldName, @dbName, @fieldType, @fieldSize

while @@fetch_status = 0
begin
    insert into #SqlCommands values ('alter table ' + @dbName + '..' + @tableName + ' alter column [' + @fieldName + ']' + @fieldType + '(' + @fieldSize + ') collate ' + cast(serverproperty('collation') as varchar(256)), '')
    
    fetch next from d into @tableName, @fieldName, @dbName, @fieldType, @fieldSize
    
end

close d
deallocate d

declare @errVal int

declare e cursor for select sql, result from #SqlCommands for Update of result

open e

fetch next from e into @sql, @errVal

while @@fetch_status =0
begin
    print @sql
    --exec @errVal = sp_executesql @sql
    update #SqlCommands set result = @@Error where current of e
    fetch next from e into @sql, @errVal
end


close e
deallocate e

select * from #SqlCommands


drop table #SqlCommands
drop table #fields


And you can download the source code for the SqlBatchRunner.
9/12/2005 11:08:16 AM (GMT Daylight Time, UTC+01:00)  #      SQL  | 
 Tuesday, September 06, 2005

I've had a few referrals for spider eating a chicken. As it's something I saw earlier in the week, this maybe what they are looking for.

Video: Camel Spider Eats A Meal
9/6/2005 8:04:34 PM (GMT Daylight Time, UTC+01:00)  #      Misc  | 
 Wednesday, August 31, 2005

BrowserLauncher is a small windows forms application which acts as an intermediary between launching a url and the web browser.

My default browser these days is Firefox, but a number of sites that I access frequently Firefox can not handle. This isn't because Firefox is broken, it's just that the sites are written particularly badly. Also there are a number of sites which I want launched in their own browser.

So I wrote BrowserLauncher. When this runs it registers itself as the default browser through manipulating the StartMenuInternet registry key - it then adds itself to the HKCR\http key. The next time you launch a URL from the desktop, start bar or ShellExecute - the details are passed to BrowserLauncher. BrowserLauncher will search its list of browser entries and launch the URL with the specified browser.

Additionally I've added some DropMyRights code that allows you to launch the browser with 3 levels of privilege, therefore allowing IE to run in Normal or Constrained mode.

Please note:

  • This software works for me, it may not work for you, if you have a bug please let me know and I'll endeavour to fix it.
  • The software will try to manipulate some registry keys.

8/31/2005 9:57:23 AM (GMT Daylight Time, UTC+01:00)  #      .net | BrowserLauncher | c-sharp | Downloads | Source Code  | 
 Tuesday, August 30, 2005

Argh, I've been getting these exceptions being thrown in a windows forms app. I've thought that the error was simply too common an error, however it seems that there are many people out there suffering the same problem.

 

8/30/2005 9:41:35 AM (GMT Daylight Time, UTC+01:00)  #      .net  | 
 Friday, August 26, 2005

I've started using NCover to monitor the test coverage on a CruiseControl.net project. Disappointed with the included version of the ncover report I quickly through together a new version of the NCover.xsl to be used by CruiseControl.net. Simply download the file and copy it to: cruisecontrol.net/webdashboard/xsl/

It's based on the original ncover.xsl but inspired by the version from Yves Lorphelin's code coverage tool NCover

8/26/2005 9:09:46 AM (GMT Daylight Time, UTC+01:00)  #      CruiseControl.net | XSLT  | 
 Wednesday, August 24, 2005

And about time too, it's been more than a year since I forecast the entry into the IM market. Google have finally joined in the fray:

http://talk.google.com/

It's more like the very first yahoo messenger I used in 1998, no icons, no group chats. The windows do dock rather nicely, and it has an exceptionally small footprint. The gmail notifier is also vastly improved allowing you to navigate a preview of your emails.

Unsurprisingly it's in beta, but that's to be expected atleast for the next few years.

8/24/2005 9:10:19 AM (GMT Daylight Time, UTC+01:00)  #      gmail | Misc  | 
 Friday, August 05, 2005

http://googleblog.blogspot.com/2005/08/keyword-chefs.html

I don't even want to describe the options available in our café.

Hopefully Google will take over the world and we'll all have to live the google way.

8/5/2005 9:50:43 AM (GMT Daylight Time, UTC+01:00)  #      Misc  | 
 Thursday, June 23, 2005

Strange ideas flow through your mind when you are frantically soothing a child for an hour early in the morning, one such thought is:

If sunflowers follow the sun  what would happen if one were planted at the arctic. Assuming of course that you could find a suitable growing medium.

 

6/23/2005 4:15:33 PM (GMT Daylight Time, UTC+01:00)  #      Misc  | 
Copyright © 2008 Rhys Jeremiah. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme: