I am new in sql azure. Now i am facing a big problem that is because of SQL Azure federation. In one of my project I want to use federation. For that I want to read data from all federation. How can I check total number of federation in the server and read data from the federation? And also how can I insert data into the federation?
currently I am using:
string strSQL = @"SELECT f.name, fmc.federation_id, fmc.member_id, fmc.range_low, fmc.range_high " +
"FROM sys.federations f " +
"JOIN sys.federation_member_distributions fmc " +
"ON f.federation_id=fmc.federation_id " +
"ORDER BY fmc.federation_id, fmc.range_low, fmc.range_high";
string strTableName = "federation_member_distributions";
try
{
using (SqlConnection connection = new SqlConnection(csb.ToString()))
{
connection.Open();
sbResults.AppendFormat("-- Open {0}\r\n\r\n", csb.ToString());
data = new DataSet();
data.Locale = System.Globalization.CultureInfo.InvariantCulture;
using (SqlCommand command = connection.CreateCommand())
{
// Connect to federation root or federation member
command.CommandText = "USE FEDERATION ROOT WITH RESET";
command.ExecuteNonQuery();
sbResults.AppendFormat("{0}\r\nGO\r\n", command.CommandText);
}
//Retrieve federation root metadata, and populate the data to the DataGridView control
SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(strSQL, connection);
sqlDataAdapter.Fill(data, strTableName);
sbResults.AppendFormat("{0}\r\nGO\r\n", strSQL);
}
}
catch (Exception ex)
{
}
but it does not work
For your above questions you really need to look these articles which talks about how to use SQL Azure Federation:
Introduction to Fan-out Queries for Federations in SQL Azure (Part 1): Scalable Queries over Multiple Federation Members, MapReduce Style!
Above you can find Fanout sample tool which has the code that show you how to get data out from Federation(s).
The second part of this sample “Fan-out Querying for Federations in SQL Azure (Part 2): Scalable Fan-out Queries with TOP, ORDER BY, DISTINCT and Other Powerful Aggregates, MapReduce Style!” show how you can run fan-out queries with particular examples.
Try above sample and let us know if you met any problem.