Question

I'm migrating an application to SQL Azure Federation and I d'like to see and edit the tables content without SQL (it's just for testing).

With a standard SQL database (SQL Server or SQL Azure) I can use one of these :

  • Management Studio (SSMS) to see and edit data : right click on a table > edit top xx rows.

  • Visual Studio : in server explorer, I connect to my database, right click on a table, and click on "Show table data".

Of course this doesn't work for SQL Azure Federation. Do you know a tool (even simple), free (if possible), to edit my data in a federation member ?

Was it helpful?

Solution

Btw, you can't use Edit top xxx rows from SSMS when connected to SQL Azure database. This option is disabled (it even is not listed on the context menu).

However it works with Visual Studio (Visual Studio 2012 SQL Server Explorer) though. Which is interesting.

And it works with Federations too. Your Federation Members are actually a separate databases with some strangely generated names. Connect with VS SQL Server Explorer to the SQL Azure Server. Then when you list all the databases in the tree you shall see other Databases, beside your federation root:

SQL Azure Federations

Now the only thing left is for you to know which system-xxxxx database corresponds to which federation member. You may be able to find this from that article. The following query might be helpful:

-- Route connection to the federation root
USE FEDERATION ROOT WITH RESET
GO
-- View the federation root metadata
SELECT db_name() [db_name]
SELECT * FROM sys.federations
SELECT * FROM sys.federation_distributions
SELECT * FROM sys.federation_member_distributions ORDER BY federation_id, range_low;
GO

Your task is fairly easy achievable when you have just one federation with only one federation member (because you will only have a single system-xxx-xxx-x DB). But as soon as you split, you will want to find out which exact federation member database you need to talk to.

UPDATE

There is one reliable way to get the exact database name for a particular federation member. You have to connect to the federation member you want to edit data in. For instance if our Federation is named MyFirstFederation and federation distribution key name is FederationKey, and we want to connect to the federation member where data with 10000 for value of Federation key is, we execute:

USE FEDERATION MyFirstFederation(FederationKey = 10000) WITH RESET
GO

On the same context we execute:

SELECT * FROM sys.databases
GO

This will list master and system-xxxx-yyy-zzz. Where the former will be the exact database which holds members with FederationKey values of 10000 (and everything else withing the range of that particular federation member).

Now we know the exact name of the database we want to select in Visual Studio 2012 SQL Server Explorer and will be able to visually edit content. It is a bit slow though, but it is a GUI tool you are asking for.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top