Posts Tagged ‘linkedin’

Turbocharge your SQL development: get more out of SQL Server Management Studio

Tuesday, December 14th, 2010

When SQL Server 2000 became SQL Server 2005, a huge number of things changed. DTS became SQL Server Integration Services, and as part of the package we saw the likes of Analysis Services and Reporting Services. All these additions to the SQL Server family necesitated a change in the suite of management tools – and that meant the death of Enterprise Manager and SQL Query Analyzer, tools loved by everyone, everywhere. They were combined and rebranded as a single tool: SQL Server Management Studio. DBAs and SQL developers cried out in horror – the new tool was, well, new – it was very different and required a change in working practice. What’s more, there was no choice – if you wanted SQL Server you had to use SSMS – there’s no using Enterprise Manager (although you can use SSMS to manage SQL Server 2000.)

The thing is, SSMS actually provides a lot of productivity tools to make your life easier, but they often go overlooked as people are used to working in Enterprise Manager, even now, some 6 years after it was released with two further releases since (SQL Server 2008, SQL Server 2008 R2). So here’s a quick look at some of the things you can do to speed up your development work, without even touching on the core features of SQL Server.

1) Explore the context menus

All items in SSMS have a context menu from the right click, and most, if not all, database objects provide a wealth of ability to quickly script tasks to either a query, a file or the clipboard. For instance, right click a table, click SELECT TO > Query Window and you’ll be provided with a query window with a full list of fields you can select. In SSMS for SQL 2005, the SELECT TOP ROWS option was removed. In SSMS 2008, it’s back in. You can rapidly build store procedures and other scripts using this functionality.

2) Empower the editor – search and replace with regex

Imagine you’ve used tip 1 to output 100 lines of SELECT SQL to a new query window. But you want to refactor it a bit. You could either edit each line by hand (yawn) or use some Regex. CTRL + H opens up the find/replace window.

Example 1

– Find e.g., ,<CaseKey, varchar(50),>)
,\<{[a-zA-Z ]+}, [a-z]+[\(\)0-9]+,\>

– Replace with e.g., ,CaseKey = ”
,\1 = ”

Example 2

Text:
”                                          AS [Some Alias Name],

Regex:
{”}:b+AS:b{\[[a-zA-Z ]+\]},

Square brackets optional
{”}:b+AS:b{[\[a-zA-Z \]]+},

Replacement:
,\2 = ”

Produces:
,[Some Alias Name] = ”

3) Visual Studio style development . The editor inherits some of the functionality that you can get in Visual Studio. Explore the keyboard shortcuts, e.g., CTRL+K, CTRL + C to quickly comment out a section*.

We also get simple debugging

And in SSMS 2008, the piece of resistance everyone wanted, Intellisense:

4) Zero in on errors

If the VS style debugger isn’t your thing, you easily debug and check the syntax and run any piece of your script at any time, simply by selecting it and CTRL + F5 to check syntax, or just F5 to run it. So if you’re testing a long sproc, you can quickly check individual blocks by selecting each one in turn and hitting F5.

5) Deployment made easy

When deploying a database, questions are always asked… should I backup and restore to the new site, or recreate it by hand, or? Well that question just got answered: use the built in Generate Scripts functionality to quickly create all the SQL required to build the database. Useful for deployment or DR scenarios:

Hopefully some of the tips will make your SQL development more enjoyable.

* Request to the SSMS developers: can we please get more of these quick formats? CTRL + K, CTRL + D would be the obvious one to quickly format an area of code, especially the code created by the visual editor, which is ugly! For now, an online tool will have to suffice.

Quick tip: Use OVER to get row numbers in subsets

Friday, December 10th, 2010

Consider the following. You have a set of data. Within the data are multiple subsets that share an identifier. WIthin your main set, you need to number the subsets for each item within it, e.g.,

Data

ID SubsetID Name Lots more columns…
———- ———–
1 ABC Dave
2 DEF Trev
3 DEF Bob
4 DEF Steve
5 HIJ Jim
6 HIJ Bilbo

and you want something like

ID SubsetID SubsetPosition Name Lots more columns…
———- ———–
1 ABC 1 Dave
2 DEF 1 Trev
3 DEF 2 Bob
4 DEF 3 Steve
5 HIJ 1 Jim
6 HIJ 2 Bilbo

How to achieve this? Using OVER with ROW_NUMBER(). What this essentially does is to partition your data in to the relevant subsets, and then use the window function ROW_NUMBER() to count them:

SELECT id, subsetid, subsetposition, row_number() over (partition by subsetid order by subsetid) as subsetposition, name frøm tblTable

Simple!

Guide: MOSS 2007 Multiple site collections on Port 80

Thursday, December 9th, 2010

Requirement: multiple site collections on port 80 on unique URLs in SharePoint 2007, e.g,. http://democlient1, http://someotherdemo
The scenario: you have one development machine which you use for multiple clients. Because of this, you want to host multiple site collections and allow a unique URL for each, without having to specify the port number in the URL. For example, if your machine name is SPDEV then by default your primary web application will respond on http://spdev. But you also want to have http://democlient1, http://someotherdemo, etc. There are a three ways of doing this. The two common ways are 1) assign unique IP addresses to each web application each responding on port 80, but this can be more complicated to setup and manage at the machine level, or 2) Use a non-standard port number for each web application, but this creates uglier URLs, e.g., http://democlient1:18765, http://someotherdemo:18734 etc.

Solution: It’s possible to achieve the requirement.
(more…)

Note: Web development coming full circle?

Sunday, October 31st, 2010

I was recently away on vacation in Cornwall. I took the laptop and iPad with me, expecting to rely on it for connectivity. Staying in a caravan park meant there was no WiFi, and the area in Cornwall we were in had no 3G access. So although connected, it was over GPRS, which by current standards, isn’t great.

Something occurred to me. In early days of web development, one of the major considerations was page size. At that time, the vast majority of visitors were on say 56k dialup – so big flash videos and image heavy websites were a huge no-no – they took far too long to download. It’s reasonable to assume that this requirement has gradually but surely lessened in recent years, as the ubiquity of high speed broadband has increased. We’ve gone from 512k to expecting 4mb+ within the space of a few years, and the current trend in website has changed to reflect this – designers can be far more creative in their use of images, reasonably safe in the knowledge that the majority of users will be on a decent connection. Who still uses 56k dialup nowadays? Your target demographics will surely now be on a reasonable connection, and the necessity to scrimp and compress every last byte out of a page is reduced. Right?

Well,  having spent a week on GPRS… and become increasingly frustrated by it, I wonder if developers/designers need a rethink. Mobile access to websites is set to increase massively in the next few years – the netbooks, tablets and smartphones have assured that, and so we must once again reconsider the effect of our pagesizes. It’s not reasonable to assume that all mobile users will have access to 3G speeds, so those accessing on Edge speeds or below, will definitely thank the designers who remember that they should always design for the lowest common denominator.

On the dearth of SharePoint Developers

Sunday, September 26th, 2010

Over the years, SharePoint has become firmly ingrained in many corporate networks in a huge number guises: the Intranet, document management system, website CMS, business data connector, business workflow/process manager to name but a few. From its early days as Portal Server, through various reincarnations to what it is today, SharePoint now commonly forms an integral part of many organisations’ infrastructure. SharePoint offers many features out of the box, but its biggest selling point is that it is infinitely customisable – through SharePoint designer, or for full control, Visual Studio. SharePoint exposes a full API and object model and provides a mature framework to produce any required business solution.

The problem? Whilst the Microsoft marketing engine has been working overtime, and persuading big business to adopt SharePoint as the platform of choice, something somewhere has failed to let the developers know – and there’s now a massive shortage. SharePoint developers are now so in demand that they command huge salaries, simple supply and demand.

It’s even harder in captive areas such as the Channel Islands where it’s reasonable to say that good developers only infrequently move back here with the sort of skills we’re looking for. That means that for the right people, the opportunities are endless. There’s loads of work, but where are the developers?

Needless to say, if you’re a talented SharePoint (or CRM, SQL or .NET..!) developer in Guernsey, then I’d love to hear from you.