Query multiple databases with SQL Server 2005’s new SYNONYMS aliasing feature

Programming No Comments »

In SQL Server 2005 it’s very easy to query multiple databases in the same statement.

For databases on the same server just use:

SELECT * FROM Database1.dbo.Table1 INNER JOIN Database2.dbo.Table1 ON Database1.dbo.Table1.ID = Database2.dbo.Table1.ID

GO

The statement is similar for linked servers.
To provide for changing object names in the future the new SYNONYM feature of SQL Server 2005 is very handy. It lets you declare aliases for the following objects:

  • Tables
  • Views
  • Stored procedures
  • CLR stored procedures
  • CLR functions
  • Replication filter procedures
  • Extended stored procedures
  • SQL scalar, table-valued, and inline table-valued functions

and the following statements:

  • SELECT
  • sub-selects
  • UPDATE
  • INSERT
  • DELETE
  • EXECUTE
CREATE SYNONYM ProdCat FOR AdventureWorks.Production.ProductCategory

 The synonym will then be visible in the object explorer, making them visible and transparent objects for developers:

However, editing of synonyms is not supported, they have to be dropped and recreated.

If you now try to create an object with the same name as an existing synonym you will get an error message:

(Liver Writer really blurs).

This means you can effectively reserve and block object names for linked objects in the defining database. Anyway, I’m not a DBA so don’t ask me about performance implications of synonyms for distributed queries but they seem to make working with multiple databases quite a bit easier.
For more information see the articles here and here

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Structure and Interpretation of Computer Programs PDF

Programming 2 Comments »

Structure and Interpretation of Computer Programs in tagged and optimized PDF version is available here. The book is the basis for computer science course 6.001 at MIT and quoted by Joel Spolsky’s rant about the dangers of Java Schools. You could read this book on your PDA and code away on or cut and paste the samples using the brilliant Pocket Scheme for an extremely geeky tour de force. By all means buy a copy of this unrivaled classic, also to get the famous wizard cover that’s missing from the PDF:

Structure_and_interpretation_of_computer_programs

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

ASP.NET AJAX not working, another MS timewaster

Programming No Comments »

While MS has to be commended for releasing version 1.0 the AJAX Extensions for ASP.NET on time and free of charge, the upgrade will not work for web sites which were upgraded from VS.NET 2003 and still have the <xhtmlConformance mode=”Legacy”/> tag in their web.config file. This will disable the AJAX functionality with no warning or error message whatsoever, prompting users to check and re-check the prescribed web.config updates and trying other fixes, wasting precious time. This issue has just appeared in the RTM version, still there is NOT A WORD about it in the migration guides, even though Scott Guthrie had blogged about this over a month ago. How many developer hours were wasted again by Microsoft sloppiness? How many will be pushed over the cliff into RoR land?

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Using MySQL with .NET 2.0 and Visual Studio 2005

Programming No Comments »

The time has come to evaluate MySQL as a database backend for .NET applications, in most cases replacing SQL Server rather than Access. Admittedly, Microsoft has done quite a bit over the past few years to stop the defection to open-source databases, offering SQL Server 2005 Workgroup Edition for small businesses as well as the free Express Edition.
However, there still is no platform independence and open-source sexiness included with any of these offerings.
Luckily, the entire MySQL-related stack is now maturing to make the switch tempting: MySQL from version 5 has support for stored procedures, triggers, views and (compiled C) functions. The MySQL Connector/Net 5.0 offers a ADO.NET driver to simplify development without resorting to ODBC. This connector can even be integrated with the Microsoft Enterprise Library which might entail ironing out some CLS compliance issues. To work with Visual Studio 2005 you can install the MySQL Visual Studio 2005 plugin to design MySQL objects right from the Server Explorer! So if you’re considering a cross-platform app, the Mono Project gives you the development platform and MySQL provides a high-performance database backend which is maturing to enterprise-readiness. It looks like C#/CLI could really become the “new Java”!

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Reimers.dk, home of the Google Maps .NET control, is up again

Programming No Comments »

After about 2 months downtime, Reimers.dk by Jacob Reimers is up again. You can download the excellent Google Maps control for ASP.NET 2.0, which supports version 2 of the Google Maps API. The licensed version has many more features, but I’ve worked with the free version only and will soon post some tips, especially how to enable the mousewheel zooming feature. Please note that version 1 of the Google Maps API is now dead.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]
WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in