2025年4月29日 星期二

VS CODE離線安裝套件方式

VS CODE可攜式安裝下載 https://code.visualstudio.com/download,點選windows 下.zip x64下載VSCode-win32-x64-1.99.3.zip,解壓縮到某目錄。

安裝離線版套件,例如安裝powershell套件,

先安裝最新版 powershell ,進入https://github.com/PowerShell/PowerShell

在右方Releases 會顯示最新版本號,點選進入去下載 PowerShell-7.5.1-win-arm64.msi


再到 https://marketplace.visualstudio.com/ 找需要的安裝檔vsix。


導引到https://github.com/PowerShell/vscode-powershell 一樣在右方Releases 會顯示最新版本號,點進去下載powershell-2025.0.0.vsix


開啟code.exe ,點選左方sidebar 的Extensions, 在視窗右上方 ... 選取 install from VSIX ...,就可以離線安裝所需的套件了。

心得:powershell 7功能較多,雖無像powershell 5 自帶ISE,但使用VS CODE套件也足以滿足所需,重點是還可以debug,十分方便。



2025年4月16日 星期三

tsql 不用unpivot 將columns轉rows

有個需求需要將多一筆資料的多欄位值轉成多列資料

之前都使用unpivot,試了一下直接用outer apply就可達成,十分好用。

其中concat 會自動處理null 為空值再串聯文字,所以也不用判斷isnull(col1,'')了。

declare @tab table (col1 nvarchar(10),col2 nvarchar(10),col3 nvarchar(10),col4 nvarchar(10))

insert into @tab values

('A','X','Y','Z'),

('B','X','Y',null),

('A','1','2','')

select distinct  col1,y.value

from @tab outer apply   (select * from string_split(concat(col2,',',col3,',',col4),',') where value > '') y

離線安裝SSMS 22 launched extracted application exiting with result code 0x138b

SSMS 22 安裝器下載頁面 https://learn.microsoft.com/zh-tw/ssms/install/install https://aka.ms/ssms/22/release/vs_SSMS.exe 將安裝檔下載到本機,檔案好大2.5G  https:...