SQL Server の Date 型に DbType.Date 渡しても動かない問題のドキュメントが直りました

結構前にこんなの書いてたんですが、
SQL Server Data Type Mappings のドキュメント間違ってね? - お だ のスペース

github にも issue が挙がってて後方互換性のため修正しませんってなってました。
Can't set SqlParameter.DbType to Date · Issue #21279 · dotnet/corefx · GitHub

Closing this as the bug was carried over from framework, and in framework it was not fixed for back compat reasons

これのドキュメントを直してもらいました。
SQL Server Data Type Mappings | Microsoft Docs
Date and Time Data | Microsoft Docs

.NET Core での System.Drawing (preview)

まだ preview ですが、公式っぽいのが出てました。
NuGet Gallery | System.Drawing.Common 4.5.0-preview1-26216-02

Windows Compatibility Pack for .NET Core ってのがあるみたいですねー。
Announcing the Windows Compatibility Pack for .NET Core | .NET Blog

NuGet Gallery | Microsoft.Windows.Compatibility 2.0.0-preview1-25914-04

Eclipse oxygen を Java9 で動かすと Gradle プロジェクトが作れない

めっちゃ久々に Java の環境を作ってました。
でいつものように JDKMaven、Gradle、Eclipse と落として設定していったのですが、 Eclipse で Gradle プロジェクトを作ろうとしても、wizard の最後の finish が無反応。。
import で Gradle プロジェクト読もうとしても無反応。

なんやねんとログを見てみると…

!ENTRY org.eclipse.ui 4 0 2018-01-28 10:40:19.495
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.IllegalArgumentException: Could not determine java version from '9.0.4'.
    at org.gradle.api.JavaVersion.toVersion(JavaVersion.java:70)
    at org.gradle.api.JavaVersion.current(JavaVersion.java:80)
    at org.gradle.internal.jvm.UnsupportedJavaRuntimeException.assertUsingVersion(UnsupportedJavaRuntimeException.java:29)
    at org.gradle.tooling.internal.consumer.ConnectorServices.checkJavaVersion(ConnectorServices.java:57)
    at org.gradle.tooling.internal.consumer.ConnectorServices.createCancellationTokenSource(ConnectorServices.java:39)
    at org.gradle.tooling.GradleConnector.newCancellationTokenSource(GradleConnector.java:95)
    at org.eclipse.buildship.core.util.progress.ToolingApiJob.<init>(ToolingApiJob.java:57)

eclipse.ini から -vm で JDK8 に変えたら動きましたとさ。

ここらへんの問題なのかな?
Import Gradle existing projects doesn't work with Java 9 · Issue #574 · eclipse/buildship · GitHub

SQL Server で既存のテーブルの CREATE TABLE を出力する方法

質問されたのでちょっと調べてみた。

  1. SSMS (SQL Server Management Studio)
  2. SQL Server Data Publishing Wizard
  3. mssql-scripter
  4. Object Catalog View (sys.~)
  5. SMO (SQL Server Management Object)

sp_helptext (TRANSACT-SQL) | Microsoft Docs はダメでしたー。
他にも何かあるかも。。

T-SQL テーブル定義の取得 (Temporal Table / Graph Table 対応版)

【訂正版】 テーブル定義の取得 - お だ のスペース の改訂版

Temporal Table と Graph Table を考慮したテーブル定義の取得クエリ。

SELECT 
  schemas.name as SCHEMA_NAME,
  object_name(cols.object_id) as TABLE_NAME, 
  case 
    when cols.graph_type in (2, 5, 8) then SUBSTRING(cols.name, 0, PATINDEX('%[_]%', SUBSTRING(cols.name, PATINDEX('%[_]%', cols.name) + 1, 100)) + PATINDEX('%[_]%', cols.name))
    else cols.name 
  end as COLUMN_NAME, 
  cols.is_nullable AS IS_NULLABLE, 
  types.name as DATA_TYPE, 
  case 
    when keys.column_id is not null then CONVERT(BIT, 1)
    else convert(bit, 0)
  end as IS_KEY, 
  case 
    when types.name in ('char', 'varchar') then cols.max_length 
    when types.name in ('nchar', 'nvarchar') and cols.max_length > 0 then cols.max_length / 2
    else -1 end as MAX_LENGTH
FROM 
  sys.columns AS cols inner join sys.tables tables on (
    cols.object_id = tables.object_id
    and tables.type = 'U'
  ) inner join sys.schemas schemas on (
    tables.schema_id = schemas.schema_id
  ) join sys.types types on ( 
    cols.system_type_id = types.system_type_id
    and cols.user_type_id = types.user_type_id
  ) LEFT OUTER JOIN ( 
    select ix.object_id, ic.column_id
    from 
      sys.indexes ix 
      inner join sys.index_columns ic on ix.object_id = ic.object_id and ix.index_id = ic.index_id
    where ix.is_primary_key = 1
  ) AS keys ON ( 
    cols.object_id = keys.object_id
    and cols.column_id  = keys.column_id
  ) 
WHERE 
  cols.is_hidden = 0
  and tables.temporal_type <> '1'
ORDER BY 
  schemas.name,
  tables.name, 
  cols.column_id

SSMS スクリプト作成の詳細オプション で指定可能なエディションがいつの間にか増えてた

久々に SQL Server Management Studio(SSMS) からオブジェクトのスクリプトを作成する機会があったので見てたら、いつのまにか Edition 毎にスクリプトを生成出来る様になってました。

記憶にあるのは、スタンドアロン(SQL Server) か Azure SQL Database かどちらかを選ぶだけだったんですけどねー。

*1は、

です。

Azure 用は、SQL DB、SQL DW と選べるように。
スタンドアロンは、Enterprise、Express、Standard は良いとして、Personal って SQL Server 2000 のやつ?

Microsoft SQL Server Stretch Database Edition は、Stretch Database | Microsoft Docs はこれ用?
SqlServer ManagedInstanceEdition は、名前の区切りもあれだしまだこれからなんでしょうけど、Azure SQL Database Managed Instance のことかなー?
Put your databases on autopilot with a lift and shift to Azure SQL Database | Blog | Microsoft Azure

*1:SSMS 17.4