LoginSignup
6
6

More than 5 years have passed since last update.

Sql Serverで取得項目をマスクする方法

Posted at

たまに使うのでメモ
以下のSQLを実行すると、取得項目にマスクできます。

SQL

SELECT
    ID
    , NAME AS NAME
    , REPLACE(Name, SUBSTRING(NAME, 2, LEN(NAME)-2), REPLICATE('*', LEN(NAME)-2)) AS MASK_NAME
FROM 
  MASK_SAMPLE

実行結果

ID NAME MASK_NAME
1 名前1 名*1
2 名前2 名*2
3 名前3 名*3
4 名前名前4 名***4
6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6