This is one of those nice features that when you stuble upon it you wonder how you ever lived without it. Just about every DBA, as well as pretty much ever developer, I know has a collection of sql scripts they save some where for reuse to do their job.
I was looking through menus for an un-related item, and out of curiousity, opened the Template Explorer (or CTRL+ALT+T) and wow, it has been open ever since.

Out of the box for SQL Studio Management Studio 2005 and 2008 it has quite a few nice little templates that are just the simple, SELECT, INSERT, etc but ones that may not be used daily and were you would normal google for the correct syntax or commands to use.
There is even a dialog to populate the values (Query or right click in the Query Window -> Specify Values for Template Parameters) works just like populating values when you execute a stored procedure.
The beauty though with the Templates is that you can define your own. Right click on any folder in the Template Explorer and select New. I was able once to save an existing query window as a Template but trying to repeat the steps, the options are no longer available. It also had the downside that the Template wouldn’t be visible in the Template Explorer until you restarted SQL Studio Management Studio. If anyone has gotten this to work for them then please let me know.
Specifying parameters is fairly easy and takes the form:
< Parameter Name , Data Type , Default Value >
My only beef with the Template Explorer is the Search – it uses Windows built-in Indexing Search/Service (what ever it is called) which I have no use for since it doesn’t work. I really with they just had a simple Filter box on the toolbar of the Template Explorer that would do a full text search of the templates. Possibly with a few terms to match common names to queries or Template names, such as CTE for Common Table Expressions.
Did I mention it has templates for MDX thought…
Read more
I’m all for adding new language constructs but this one I just can’t endorse – implicity typed variables.
Now, I’m not a fan of scripting languages (perl, javascript, python, etc) and am pretty sure I’m not I’m ever going to use this.
So instead of writing
string url = "http://mymojo.ca";
int port = 80;
you can write
var url = "http://mymojo.ca";
var port = 80;
And everything is suppose to just work as if it were strongly typed.
var x = 5;
var y = "11";
var z = x + y;
And what is the result of z - 16 or “511″?
Read more
I’ll admit it, I’m new to WPF. But have been spending the last week or so (when I have time) to go through Hands On Labs or any other tutorials I can find to get up to speed. And now that I’m done, I wanted to apply my new found knowledge and build something without a helping hand – something simple, WPF for display, using LINQ in the data access layer and SQL for the backend data store.
SQL and LINQ was the easy part. Business entities all setup, data access layer is work and then…
stopped. WPF – ugh! To be fair some of the issues aren’t specific to WPF.
- Expression Blend doesn’t play nicely with Visual Studio 2008 C# Projects
- Auto-complete for XAML files works sometimes – which is frustrating if you are trying to learn it
- Lack of online samples (or samples that are questionable in terms of code, i.e., not using a using statement when working with a database connection) that have full CRUD
But really, my biggest beef is with Visual Studio 2008. What I was really hoping for was ASP.NET 2.0 data-binding in WPF – little handles over a control, wizards to setup which binding source to be used, auto-generation of SQL commands, etc, etc, etc. Prototyping was dead easy and you could have a small data bound web application up in minutes. Sadly this is all missing – not only making the barrier to entry to WPF that much higher.
Might just have to break down and get a book…
And if you haven’t grabed the Visual Studio 2008 and .NET Framework 3.5 Training Kit yet:
http://www.microsoft.com/downloads/details.aspx?FamilyID=8BDAA836-0BBA-4393-94DB-6C3C4A0C98A1&displaylang=en
Read more
Well, it has been a little while since my last post. So to get back into things, I thought I would provide some insights into how to use COM interop to display a widget in the taskbar and specifically a graphical display of the battery power for a laptop. I should take a step back and explain, Lenovo has IMHO a great litle utility (see image below) which when I got my new VAIO for Christmas sadly does not come with.

Plus I downloaded Visual Studio 2008 from MSDN and needed a little project to play around with. So after a little google’ng I found two articles that explained pretty much what I needed and all I needed to do was put them together and presto, I too could have the utility on my new VAIO.
The first is how to use COM interop to extend Internet Explorer and Band Objects with C#
http://www.codeproject.com/KB/shell/dotnetbandobjects.aspx
and the second is regarding Power Awareness and Mobility with .NET
http://blogs.msdn.com/coding4fun/archive/2006/11/12/1066558.aspx
And with a little synergy later:

Since the transparency is a little off (well, isn’t transparent at all), I’m going to hold off posting the code until I can find the time to get it sorted.
Ideas for future development:
http://www.codeplex.com/vistabattery
Read more
We are all familar with
SELECT A.* FROM dbo.TableA
WHERE ColumnA BETWEEN ValueA AND ValueB
If not then please see http://msdn2.microsoft.com/en-us/library/bb264565.aspx.
Which is all fine and dandy if you have one value for ValueA and one value for ValueB. But what happens say if you have multiple values, say stored in another table.
Cursors? Shame for even thinking it. My DBA would rap your knuckles if he even suspected you were thinking about.
A WHILE Loop? Sure. And to be honest I have used that in the past as well.
But there is a better way with a lot less SQL.
SELECT A.* FROM dbo.TableA A
INNER JOIN dbo.TableB B ON
A.ColumnA BETWEEN B.ColumnY AND B.ColumnZ
Tell me that doesn’t look nice and simple. So go on, replace those while loops, I can wait…
Read more