我是sql azure中的新成員。現在我面臨着一個很大的問題,那就是因爲SQL Azure聯合。在我的一個項目中,我想使用聯邦。爲此,我想讀取來自所有聯邦的數據。如何檢查服務器中的聯合總數並從聯合數據中讀取數據?還有我該如何將數據插入聯合會? 目前我使用:聯邦扇出查詢
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)
{
}
,但它不工作
偉大而有用的答案! – JYL