Sql-Server

如何在 SQL Server 中列出可用的強制轉換?

  • July 13, 2018

在 PostgreSQL 中,有一個命令,\dC+我可以在 psql 中使用\dC+

\dC[+]  [PATTERN]      list casts

列出可能的CASTS. 這很有用,因為我可以很容易地找出可以用來投射到的東西timestamp

\dC+ timestamp
                                            List of casts
        Source type         |         Target type         |  Function   |   Implicit?   | Description 
-----------------------------+-----------------------------+-------------+---------------+-------------
abstime                     | timestamp without time zone | timestamp   | yes           | 
date                        | timestamp without time zone | timestamp   | yes           | 
timestamp without time zone | abstime                     | abstime     | in assignment | 
timestamp without time zone | date                        | date        | in assignment | 
timestamp without time zone | timestamp without time zone | timestamp   | yes           | 
timestamp without time zone | timestamp with time zone    | timestamptz | yes           | 
timestamp without time zone | time without time zone      | time        | in assignment | 
timestamp with time zone    | timestamp without time zone | timestamp   | in assignment | 

SQL Server 中是否有類似的命令?我怎樣才能找到我 CAST做到的DateTime2?這在任何地方都有記錄嗎?

CAST 和 CONVERT的Microsoft Docs 頁面在 SQL Server 中提供了一個很好的轉換矩陣。

上述頁面中包含的圖像:

在此處輸入圖像描述

據我所知,沒有用於顯示有效演員表列表的內置機制。

引用自:https://dba.stackexchange.com/questions/212186