Jane's Technical Stuff

Wednesday, November 28, 2007

DDD6 Review


On Saturday I attended the 6th of the DDD days held at Microsoft campus in Reading. This was my first DDD, although I have attended a WebDD and the recent SQLBits day this year.

The day was again broken into 5 sessions, with 4 streams. The sessions I attended were:
I was pleased with my session choice and gained lots from all the speakers. I combined some talks that I knew aspects about (like the Continuous Integration one) with those that I'd not come across before (ASP.NET dynamic data controls - which look really handy for admin sites etc, and Astoria). I had to do a swift session swap for session 3 as I'd sat myself down ready to learn about Business apps with WPF with Oliver Sturm when he mentioned it was part 2 and I'd misread the agenda. Still, I got to learn about astoria which was really interesting and sounds really useful. My final session of the day was silly yet fun as Dave and Richard led a mass schwag giveaway hosting a game of "A question of swag" followed by a game of "Swaggity Swag".

The schwag bag wasn't great, consisting of just a pen - not even a notebook this time - but the hour of free training that innerworkings provided is a great gift to come away with.

All in all, another great developer conference and an opportunity to catch up with some familiar faces from the previous days.

Labels: ,

// posted by Jane @ 6:28 PM   save to del.icio.us

Comments:

Tuesday, November 13, 2007

VBUG Brighton - Visual Studio 2008 and .Net Framework 3.5


This evening Madgex hosted the first of what I hope will be many VBUG events. After a really informative session in August on LINQ I had high hopes for this evening, and wasn't dissapointed. Daniel Moth gave a rapid, but informative, tour of Visual Studio 2008 and some of the new features of .Net framework 3.5

As with the last event the format was a talk for about an hour, then a break for pizza and beer before heading back for another half an hour or so.

Pizza at VBUG Brighton

Looking at my notes, again there is a jumble of keywords to go and find out more about. The multi targeting element of Visual Studio 2008 looks great with the ability to swap which framework you're working against simply by selecting from a list. In fact, it seems like the only downside to upgrading to VS2008 is that it will have to be an all or nothing approach for any project with more than one developer - the .sln file has a different format and is the only bit which won't be compatible with VS2005. The inclusion of the Expression Web seems sensible - I remember being impressed by that when I saw a demo earlier this year at WebDD - and I'm particularly keen to see the CSS and javascript intellisense. I'm also hoping the manage styles window will help me get to grips with the precedences of element vs IDs vs classes in CSS as well!

Some of the new language features seem like they're included to be time savers (like var and anonymus typing), which at the moment at least I can't see being of help to the developer coming along later to maintain the code. I can also imagine the lambda expressions taking a while to get used to.

All in all, another excellent evening, and again a pleasure to see our office space being used for another community event.

Labels: , , ,

// posted by Jane @ 10:28 PM   save to del.icio.us

Comments:

Generate SQL Insert statement from table data


Years ago I stumbled upon a helpful SQL script (SQL Server 2000 and 2005) written by a chap called Keith E Kratochvil which you could point at a table in your database and which would then generate a series of Insert scripts.

I made some amendments at the time and over the next few years to make a bit more useful to me for some specific requirements, including the ability to take bits of a where clause to restrict the data coming back, allowing me to script subsets of data. I've carried this script with me from company to company, and decided it was time to share the updated script.

One word of advice, before running the generated inserts, do a replace of 'NULL' with NULL as I failed to get NULLs appended to a string without causing the whole string to become NULL.

The procedure is available here so feel free to take a look and use it if you find it helpful.

Labels: , , ,

// posted by Jane @ 5:39 PM   save to del.icio.us

Comments:
Used this again today - thanks!
 
Hi Jane.

Ran the sp and got the following errors:

-- ** Start of Inserts

Msg 536, Level 16, State 5, Procedure sup_GenerateInsert, Line 151
Invalid length parameter passed to the SUBSTRING function.
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'FROM'.
-- ** End of Inserts

Probably "user error" but I would appreciate any insights you might be able to offer.

Thanks.
 
Hi Dave

You haven't left me an email address or any other way to contact you, and your blogger profile is switched off or similar, so I'm hoping you're going to head back here and take a look.

There is a section in the script which looks like the following:

SELECT @SelList = SUBSTRING(@SelList, 1,(len(@SelList)-1))
SELECT @SelList = @SelList + ' FROM ' + @table
--SELECT @SelList AS TheSelList

I recommend uncommenting the "SELECT @SelList AS TheSelList" line to help enable debugging.

I'd be interested in seeing what is being generated, and the structure of the table you're running it against if you have the time. I'll then try and sort out the problem and update the stored procedure and hopefully fix the problem. Drop me a line at jane(@)dallaway.com - without the ()s of course :-) with any information you have to help.

Thanks
Jane
 
Hi Jane,

A possible enhancement or improvement would be to use the UNION operator instead of Values. You would then have one SQL statement to execute instead of multiple. In addition, the script would generate much less text (only one INSERT INTO line) and make it easier to scan the data.

I modified the print out section of script to do this. I haven't tested it thoroughly, but it seems like a pretty straightforward modification. I removed one of the carriage returns so there's no space between UNION lines. Thanks for the script, it was helpful.

Jon Green - 4R Systems Inc.

Here's the code I modified.

--Cursor through the data to generate the INSERT statement / VALUES clause
DECLARE CR_Data CURSOR FAST_FORWARD FOR SELECT TableData FROM #TheData FOR
READ ONLY
OPEN CR_Data
FETCH NEXT FROM CR_Data INTO @TableData

if (@@fetch_status <> -1)
Print @InsertStmt + char(13) +
'SELECT ' + @TableData

FETCH NEXT FROM CR_Data INTO @TableData

WHILE (@@fetch_status <> -1)
BEGIN
IF (@@fetch_status <> -2)
BEGIN
PRINT 'UNION SELECT ' + @TableData

IF @generateGo = 1
BEGIN
PRINT 'GO'
END
END
FETCH NEXT FROM CR_Data INTO @TableData
END
CLOSE CR_Data
DEALLOCATE CR_Data
 
Thanks for your suggestion Jon. I've implemented a change based on what you've suggested. I've blogged a reasonable description of what I've changed, and why - but basically I've added a new optional parameter @producesingleinsert to control whether multiple INSERT statements are generated, or a single statement using INSERT, SELECT and UNION SELECT.

New script available here
 
Hi, very usefull script, I added one more parameter to it:
@GenerateOneLinePerColumn BIT = 0

If you want each columns being generated in a separate line, this is usefull to easily compare the generated file with a source control system.

I have all the code available if somebody wants it, most of it consist of statement like :

+ CASE WHEN @GenerateOneLinePerColumn = 1 THEN ' + CHAR(13)+' ELSE '' END +
 
Thanks Christian

Sounds like a great addition :-)
 
Jane awesome job, thanks, saved a ton of time...and a little money too! - Don
 

Wednesday, November 07, 2007

Brighton and Hove Web Awards - Brighton Bloggers is shortlisted



Web Awards Nomination
Brighton Bloggers has been shortlisted on the Brighton and Hove Web Awards list in the Best Local Online Community category.

This is vaguely amusing as it because of my involvement with the Web Awards in 2003 that Brighton Bloggers was born out of a list produced by Joh. It was originally intended to last for the length of the festival, but I felt this was a waste and decided to create Brighton Bloggers with help, support and encouragement at the time from Pete and Jeremy.

Time has moved on, and the site now lists 267 bloggers who either work or live in Brighton and another successful meetup happened just last week.

Please consider supporting Brighton Bloggers by submitting your vote

Labels: , , ,

// posted by Jane @ 7:21 PM   save to del.icio.us

Comments:

Copying a database on SQL Server 2005 using Backup and Restore


I always forget to do this, so this is a reminder for me. Hope it comes in handy for others too.

One of the things I do quite often, but obviously not enough, is to create a new database based on an existing one. I've tried various methods over the years, but backup and restore seems to work reliably and without too many headaches, and it doesn't involve taking the database offline either.

So, for instance to create a new database named JaneDallawayTest from and existing database called JaneTest I would do the following:
Backup JaneTest and store the resultant file somewhere I can get hold of it from
Then restore that backup to a new database named JaneDallawayTest by executing the following SQL:
RESTORE DATABASE [JaneDallawayTest]
FROM disk = N'JaneTestBackup.bak'
WITH FILE = 1 ,
move N'JaneTest'
TO N'G:\SQLData\JaneDallawayTest.mdf' ,
move N'JaneTest_log' TO N'G:\SQLData\JaneDallawayTest_log.ldf' ,
nounload , stats = 10 , replace
GO


All that is left to do is to update the logical name for the new database in the Database Properties dialog.

Labels: , ,

// posted by Jane @ 3:29 PM   save to del.icio.us

Comments:

Thursday, November 01, 2007

A week of skillswaps


Booking is now underway for the week of Skillswap events which are being run during the Brighton Digital Festival. These events are "Informal training by the local community for the local community" and I've been to a couple before. The events are:
Danny approached me a while ago about doing a photography talk, and so I've got a couple of weeks to prepare. My plans are to do a Tips for digital photographers session initially, and I'd really like to then move on to a critiquing session where the attendees (and me!) put forward photos to be reviewed by the other attendees. This is an excellent way to learn, and I'm far from being an expert and want to learn too.

Labels: , , ,

// posted by Jane @ 7:29 PM   save to del.icio.us

Comments:

Brighton Bloggers   This page is powered by Blogger. Isn't yours?   rss Sussex Digital - focusing on the Sussex digital community