SQL Server で置き換えようとしてCHAR(0)
い''
ますが、フィールドが実際にはフィールドであるため機能しません。NVARCHAR
照合順序はLatin1_General_CI_AS
、変換すると.SQL_Latin1_General_CP1_CI_AS
VARCHAR
NVARCHAR
SELECT val, REPLACE(val , CHAR(0), 'x')
FROM (
SELECT 'a' + CHAR(0) + 'b' AS val
) AS X
戻り値a | a
SELECT val, REPLACE(CAST(val COLLATE SQL_Latin1_General_CP1_CI_AS AS varchar(100)), CHAR(0), 'x')
FROM (
SELECT 'a' + CHAR(0) + 'b' AS val
) AS X
戻り値a | axb
SELECT val, REPLACE(CAST(val COLLATE SQL_Latin1_General_CP1_CI_AS AS varchar(100)), CHAR(0), 'x')
FROM (
SELECT CAST('a' + CHAR(0) + 'b' AS NVARCHAR(100)) AS val
) AS X
SELECT val, REPLACE(CAST(val COLLATE SQL_Latin1_General_CP1_CI_AS AS nvarchar(100)), CHAR(0), 'x')
戻り値a | axb
FROM (
SELECT CAST('a' + CHAR(0) + 'b' AS NVARCHAR(100)) AS val
) AS X
SELECT val, REPLACE(CAST(val COLLATE SQL_Latin1_General_CP1_CI_AS AS varchar(100)), nCHAR(0), 'x')
戻り値a | a
FROM (
SELECT CAST('a' + CHAR(0) + 'b' AS NVARCHAR(100)) AS val
) AS X
SELECT val, REPLACE(CAST(val COLLATE SQL_Latin1_General_CP1_CI_AS AS nvarchar(100)), nCHAR(0), 'x')
戻り値a | a
FROM (
SELECT CAST('a' + CHAR(0) + 'b' AS NVARCHAR(100)) AS val
) AS X
戻り値a | a
0x0000
文字を置き換え''
て NVARCHAR 状態を失わないようにする方法はありますか
編集: 期待される値はa | axb
、最後のクエリ (または類似しているがNVARCHAR
.