SQL Database に Geo レプリケーションの自動フェールオーバー グループ機能がきましたー

SQL Database の Geo レプリケーション セカンダリへのフェールオーバー時の接続について - お だ のスペース でちょろっと書いてた、自動フェールオーバー グループの機能がきましたー。
公式はこちら
Azure SQL Database now supports transparent geographic failover of database groups | ブログ | Microsoft Azure
日本語は SEの雑記 でさっそく試されています。
SQL Database の Geo レプリケーションに自動フェールオーバーグループの機能が追加されました at SE の雑記

落ち着いたら試してみますねー。
しかし SQL DB の強制フェールオーバーのテストって出来るんかな?

SQL Database の Geo レプリケーション セカンダリへのフェールオーバー時の接続について

ちょっと前にこれ SQL Database の障害復旧 | Microsoft Docs 読んでて

新しいプライマリ サーバーにユーザーをリダイレクトする方法を決めます。たとえば、接続文字列を変更したり、DNS エントリを変更したりすることでリダイレクトできます。

の記述が気になったので調べたんですが、DNS の変更じゃ無理じゃないかなー?
無理な理由は、Azure SQL Database のホスト名と IP アドレスの関係 – Microsoft Japan Data Platform Tech Sales Team Blog が詳しいです。

論理サーバー名を渡すのに、どうしても接続文字列のユーザー名に @servername 付けないと上手く繋がらないはず。
ドメイン取って試してみたけど、やっぱり出来なかった。
やり方知ってる人は教えて~。

ただ何日か前に
クラウド ビジネス継続性 - データベース復旧 - SQL Database | Microsoft Docs
に「自動フェールオーバー グループ」と「フェールオーバー グループリスナー」って単語が出てきたので期待。

5/20(土) 第5回 関西DB勉強会 開催します!

今年最初の関西DB勉強会です~。

今回は 初心者から上級者まで楽しめるよう勉強会をテーマにしています!
kansaidbstudy.connpass.com
そのため時間もいつもより長めで 12:00 ~ 19:00 となっています。
お時間あるかたは是非ご参加を~。

懇親会も是非ご参加ください~。
kansaidbstudy.connpass.com

SQL Server Data Type Mappings のドキュメント間違ってね?

SQL Server の Date 型に ADO.NET の DbType.Date はうまく動かない - お だ のスペース の続き
SqlParameter.cs 見てみました。

corefx/SqlParameter.cs at v1.0.4 · dotnet/corefx · GitHub
Reference Source

set
{
    MetaType metatype = _metaType;
    if ((null == metatype) || (metatype.DbType != value) ||
            // Two special datetime cases for backward compat
            // DbType.Date and DbType.Time should always be treated as setting DbType.DateTime instead
            value == DbType.Date ||
            value == DbType.Time)
    {
        PropertyTypeChanging();
        _metaType = MetaType.GetMetaTypeFromDbType(value);
    }
}

DbType.Date と DyType.Time の場合は、下位互換のために 毎回 MetaType を更新してますと。
で MetaType.GetMetaTypeFromDbType で何してるかというと、
corefx/SqlEnums.cs at v1.0.4 · dotnet/corefx · GitHub
Reference Source

internal static MetaType GetMetaTypeFromDbType(DbType target) {
    // if we can't map it, we need to throw
    switch (target) {
    case DbType.AnsiString:             return MetaVarChar;
    case DbType.AnsiStringFixedLength:  return MetaChar;
    case DbType.Binary:                 return MetaVarBinary;
    case DbType.Byte:                   return MetaTinyInt;
    case DbType.Boolean:                return MetaBit;
    case DbType.Currency:               return MetaMoney;
    case DbType.Date:
    case DbType.DateTime:               return MetaDateTime;
    case DbType.Decimal:                return MetaDecimal;
    case DbType.Double:                 return MetaFloat;
    case DbType.Guid:                   return MetaUniqueId;
    case DbType.Int16:                  return MetaSmallInt;
    case DbType.Int32:                  return MetaInt;
    case DbType.Int64:                  return MetaBigInt;
    case DbType.Object:                 return MetaVariant;
    case DbType.Single:                 return MetaReal;
    case DbType.String:                 return MetaNVarChar;
    case DbType.StringFixedLength:      return MetaNChar;
    case DbType.Time:                   return MetaDateTime;
    case DbType.Xml:                    return MetaXml;
    case DbType.DateTime2:              return MetaDateTime2;
    case DbType.DateTimeOffset:         return MetaDateTimeOffset;
    case DbType.SByte:                  // unsupported
    case DbType.UInt16:
    case DbType.UInt32:
    case DbType.UInt64:
    case DbType.VarNumeric:
    default:                            throw ADP.DbTypeNotSupported(target, typeof(SqlDbType)); // no direct mapping, error out
    }
}

DbDate と DbTime は MetaDateTime 扱いになってますと。
で、SqlDbType 指定した場合は、
corefx/SqlEnums.cs at v1.0.4 · dotnet/corefx · GitHub
Reference Source

internal static MetaType GetMetaTypeFromSqlDbType(SqlDbType target, bool isMultiValued) { // WebData 113289
    switch(target) {
    case SqlDbType.BigInt:            return MetaBigInt;
    case SqlDbType.Binary:            return MetaBinary;
    case SqlDbType.Bit:               return MetaBit;
    case SqlDbType.Char:              return MetaChar;
    case SqlDbType.DateTime:          return MetaDateTime;
    case SqlDbType.Decimal:           return MetaDecimal;
    case SqlDbType.Float:             return MetaFloat;
    case SqlDbType.Image:             return MetaImage;
    case SqlDbType.Int:               return MetaInt;
    case SqlDbType.Money:             return MetaMoney;
    case SqlDbType.NChar:             return MetaNChar;
    case SqlDbType.NText:             return MetaNText;
    case SqlDbType.NVarChar:          return MetaNVarChar;
    case SqlDbType.Real:              return MetaReal;
    case SqlDbType.UniqueIdentifier:  return MetaUniqueId;
    case SqlDbType.SmallDateTime:     return MetaSmallDateTime;
    case SqlDbType.SmallInt:          return MetaSmallInt;
    case SqlDbType.SmallMoney:        return MetaSmallMoney;
    case SqlDbType.Text:              return MetaText;
    case SqlDbType.Timestamp:         return MetaTimestamp;
    case SqlDbType.TinyInt:           return MetaTinyInt;
    case SqlDbType.VarBinary:         return MetaVarBinary;
    case SqlDbType.VarChar:           return MetaVarChar;
    case SqlDbType.Variant:           return MetaVariant;
    case (SqlDbType)TdsEnums.SmallVarBinary: return MetaSmallVarBinary;
    case SqlDbType.Xml:               return MetaXml;
    case SqlDbType.Udt:               return MetaUdt;
    case SqlDbType.Structured:
        if (isMultiValued) {
            return MetaTable;
        } 
        else {
            return MetaSUDT;
        }
    case SqlDbType.Date:              return MetaDate;
    case SqlDbType.Time:              return MetaTime;
    case SqlDbType.DateTime2:         return MetaDateTime2;
    case SqlDbType.DateTimeOffset:    return MetaDateTimeOffset;
    default:                          throw SQL.InvalidSqlDbType(target);
    }
}

MetaDate と MetaTime になってますね。

下位互換のために、DbType.Date と DbType.Time が SqlDbType.Date と SqlDbType.Time と動作が違うのは良いんですが、
ならドキュメントに書いといてよー。
SQL Server データ型のマッピング
日付と時刻のデータ
これ見たら、SQL Server の Date 型には、DbType.Date でも使えるように見えるよ。。

4/22(土) Global Azure Bootcamp /w OzCode 2017@Kansai で話します~

Global Azure Bootcamp /w OzCode 2017@Kansai - connpass
で1枠頂いたので、Azure ネタで話します~。

なんと OzCode: Innovative debugging extension for Visual Studio の中の人とディスカッションも出来ます!
めったにない機会だと思いますので、ご都合の良いかたは是非ご参加を~。

懇親会はこちらです
【懇親会】Global Azure Bootcamp /w OzCode 2017@Kansai - connpass

行レベル セキュリティ を使ってるテーブルで SSDT の配置がエラーになるときの回避方法

SSDT のバージョンが低いと出ないかも。

行レベル セキュリティ(Row-Level Security) を設定しているテーブルを SSDT で配置をすると以下の警告が出る場合があります。

SR0111:Microsoft.Rules.Data.DeploymentValidation:現在の操作はテーブル ~ に対するデータ モーションを引き起こします。このテーブルでは、ポリシー ~ によって行レベルのセキュリティが有効になっているた.め、このテーブルに対してデータ モーションを実行することはできません。

SQL Server Data Tools 16.3 Release | SQL Server Data Tools Team Blog
の Tip に載ってました。

To prevent an accidental data loss, deployment that requires data motion on a table with Row Level Security is blocked by default. To override the default behavior, use  SqlPackage.exe with option /p:AllowUnsafeRowLevelSecurityDataMovement=true.

英語のメッセージやったら検索しやすいけど、日本語のエラーメッセージはつらい。。
詳細設定の「安全でない行レベルのセキュリティ データ移動を許可する」をチェック入れるとOKです。
f:id:odashinsuke:20170407223816p:plain

4/18(火) SQLWorld★大阪#41 開催します

SqlWorld :: SQLWorld★大阪#41 開催します。23回目の平日夜開催で、前回同様 ハンズオン 形式行う予定です。

【日時】
2017年4月28日(火曜日) 19:00~21:00
 

【イベント概要】
SQLWorld 23回目の平日夜開催~。今回も、みんなで SQL を書いてみようというハンズオン企画です!ブラウザがあれば参加出来るようにしていますので、iPad 等のタブレットでも大丈夫です。
 

【会場】
フェンリル株式会社さま大阪本社 http://www.fenrir-inc.com/
〒530-0011 大阪府大阪市北区大深町 3番1号 グランフロント大阪タワーB(オフィス)
 

【参加費】
無料
 

【持ち物】
パソコン/タブレット (DB のインストールは不要です。)
 

【参加可能人数】
13 人
 

お題に沿って、SQL を書いてみようという勉強会です。是非ご参加を~。

開催回数は増えていっていますが、続き物というわけでは無いので初めて参加される方でもお気軽にどぞー。