Dell i3 電腦作業系統Windows 10,透過HDMI轉VGA接頭連接舊螢幕,開機螢幕偏黃,重新插拔連接線後恢復正常,異常排除。

更換VGA連接線=>更換螢幕=>更換轉接頭=>更新BIOS與intel顯卡驅動=>安裝AVAST防毒軟體=>移除最近安裝應用軟體(Microsoft Power Automate)=>進入intel顯卡設定程式任意調整設定(非相關設定)=>恢復正常

問題推斷,使用者反應自從另一位同事幫忙安裝Microsoft Power Automate後,桌面背景不定時會自行替換,檢查發現該人員安裝MPA時有微軟帳號登入,並有開啟桌面同步功能,關閉桌面同步後,桌面背景就不會自行變換,推斷此同步設定可能會影響開機時螢幕顯示相關設定,進入顯卡設定任意調整後可覆蓋此問題,因此可解決此異常,後續持續觀察。

Powershell script透過outlook每日發送刷卡資料

新增powershell script 檔案sendmail2.ps1 內容如:

$From = "0420@company.com.tw"
$To = "0420@company.com.tw","11010@company.com.tw","0260@company.com.tw","0410@company.com.tw"
$Subject = "card datas - $(Get-Date -Format 'yyyy-MM-dd')"
$Body = "card datas"
$AttachmentPath = "H:\RecData.txt"  # Specify the path to your attachment

Send-MailMessage -From $From -To $To -Subject $Subject -Body $Body -SmtpServer "192.168.x.x" -Attachments $AttachmentPath

新增工作排程 啟動程式 powershell.exe 新增引數-ExecutionPolicy Bypass -File ” C:\Users\user31\Desktop\sendmail2.ps1″

WIN11 + EpsonLQ-680連線問題排除

舊配置 AMD文書機 win10 home +USB延長線+USB 轉LPT port+LQ-680可正常列印

新配置主機換成DELL i5-12400 + win11 home 一樣連線方式,卻發生列印幾張後即中斷、列印任務卡住等異常。

問題排除一:假設-USB延長線生鏽或接觸不良導致。實作-改用USB Printer server連線方式,win11 home+網路+USB Printer server+USB 轉LPT port+LQ-680,狀況一樣,連續列印會中斷。

問題排除二:假設-USB 轉LPT port轉接線異常。實作-改用LPT Printer server 連線方式,win11 home+網路+LPT Printer server+LQ-680,狀況一樣。

問題排除三:假設-軟體或設定導致。實作-於印表機內容連接埠設定由LPR改成RAW,問題終於排除。觀測印表機工作佇列,RAW會一下子吃掉所有工作,LPR則會一個一個慢慢執行。運作模式不同而導致結果不同。

狀況二:隔週使用者反映印表機又無法使用啦!!!

問題排除四:假設-於排除三運作模式已確認可行,應為其他硬體問體導致。實作-ping printer server發現無法ping通,重啟printer server也無法ping通,換一條網路線就可以通了,此時使用者發現原來網路線被折彎,導致有個角度才會通。

總結:由於此為外點之設備,無法直接實機檢測與排除,遠端遙控使用者操作增加異常排除難度與時程拖長,期間使用者抱怨無法使用,只有耐心溝通,按照假設一步步實作,終於解決。觀察點一:原本舊機+win10直連方式換成新機+win11卻無法正常運作,還是不知原因,因為直連不須也無法設定連接埠。觀察點二:連接埠LPR與RAW運作模式之差異,導致實際使用結果不同,這兩種模式之差異與適用時機為何?

Excel公式加上大括號{}的用法

當一個公式中,含有返回一組數的表達式時,需使用數組進行運算。在公式輸入完成之後,按ctrl+shift+enter三鍵,會自動加上大括號{}{=SUM(IF(MOD(COLUMN($D4:$LB4),10)=4,$D4:$LB4,0))} 指加總範圍內每10欄的第四欄。

參考 https://www.dotblogs.com.tw/areswang/2020/10/26/Dynamic_array_formulas_2

Excel 新增自訂 function 數字轉大寫中文

Function Num2Str(Str As String) As String
For i = 1 To Len(Str)
a = Mid(Str, i, 1)
Select Case True
Case a = 0
aa = aa & “ 零”
Case a = 1
aa = aa & “ 壹”
Case a = 2
aa = aa & “ 貳”
Case a = 3
aa = aa & “ 參”
Case a = 4
aa = aa & “ 肆”
Case a = 5
aa = aa & “ 伍”
Case a = 6
aa = aa & “ 陸”
Case a = 7
aa = aa & “ 柒”
Case a = 8
aa = aa & “ 捌”
Case a = 9
aa = aa & “ 玖”
Case Else
aa = aa & a
End Select
Next i
aa = Right(“零 零 零 零 零 零 零 零 零” & aa, 18)
bb = Left(aa, 6) & ” ” & Mid(aa, 7, 2) & ” ” & Mid(aa, 9, 2) & ” ” & Mid(aa, 11, 2) & Right(aa, 6)
Num2Str = bb
End Function

Delete Duplicates From a Table in SQL Server

To delete the duplicate rows from the table in SQL Server, you follow these steps:

Let’s set up a sample table for the demonstration.

Setting up a sample table

First, create a new table named sales.contacts as follows:

DROP TABLE IF EXISTS sales.contacts;

CREATE TABLE sales.contacts(
    contact_id INT IDENTITY(1,1) PRIMARY KEY,
    first_name NVARCHAR(100) NOT NULL,
    last_name NVARCHAR(100) NOT NULL,
    email NVARCHAR(255) NOT NULL,
);
Code language: SQL (Structured Query Language) (sql)

Second, insert some rows into the sales.contacts table:

INSERT INTO sales.contacts
    (first_name,last_name,email) 
VALUES
    ('Syed','Abbas','syed.abbas@example.com'),
    ('Catherine','Abel','catherine.abel@example.com'),
    ('Kim','Abercrombie','kim.abercrombie@example.com'),
    ('Kim','Abercrombie','kim.abercrombie@example.com'),
    ('Kim','Abercrombie','kim.abercrombie@example.com'),
    ('Hazem','Abolrous','hazem.abolrous@example.com'),
    ('Hazem','Abolrous','hazem.abolrous@example.com'),
    ('Humberto','Acevedo','humberto.acevedo@example.com'),
    ('Humberto','Acevedo','humberto.acevedo@example.com'),
    ('Pilar','Ackerman','pilar.ackerman@example.com');
Code language: SQL (Structured Query Language) (sql)

Third, query data from the sales.contacts table:

SELECT 
   contact_id, 
   first_name, 
   last_name, 
   email
FROM 
   sales.contacts;Code language: SQL (Structured Query Language) (sql)

The following picture shows the output of the query:

SQL Server Delete Duplicates

There are many duplicate rows (3,4,5), (6,7), and (8,9) for the contacts that have the same first name, last name, and email.

Delete duplicate rows from a table example

The following statement uses a common table expression (CTE) to delete duplicate rows:

WITH cte AS (
    SELECT 
        contact_id, 
        first_name, 
        last_name, 
        email, 
        ROW_NUMBER() OVER (
            PARTITION BY 
                first_name, 
                last_name, 
                email
            ORDER BY 
                first_name, 
                last_name, 
                email
        ) row_num
     FROM 
        sales.contacts
)
DELETE FROM cte
WHERE row_num > 1;
Code language: SQL (Structured Query Language) (sql)

In this statement:

  • First, the CTE uses the ROW_NUMBER() function to find the duplicate rows specified by values in the first_namelast_name, and email columns.
  • Then, the DELETE statement deletes all the duplicate rows but keeps only one occurrence of each duplicate group.

SQL Server issued the following message indicating that the duplicate rows have been removed.

(4 rows affected)

If you query data from the sales.contacts table again, you will find that all duplicate rows are deleted.

SELECT contact_id, 
       first_name, 
       last_name, 
       email
FROM sales.contacts
ORDER BY first_name, 
         last_name, 
         email;Code language: SQL (Structured Query Language) (sql)
SQL Server Delete Duplicate Rows Result

https://www.sqlservertutorial.net/sql-server-basics/delete-duplicates-sql-server/

如何跳過 Win11 強制連網?

1.在連到網路的頁面,不要連上網路,也把實體網路線拔除,這時候按下鍵盤上的「Shift + F10」就可以開啟 CMD 視窗,如果按下去沒有反應,請試試看「fn + Shift + F10」組合,應該就可以順利呼叫開啟 CMD。

2.開啟之後輸入「oobe\bypassnro」,並按下 Enter 鍵。之後系統會自動重新啟動,重開機後會再進入 OOBE 畫面一次,設定都會重新來過,請依照自己需求設定。

4.到連接網路畫面時,就可以看到「我沒有網際網路」的選項,點選後就可以跳過連網!

SQL語法針對 BOM減少一階 後做用料量彙總

–bom2要被減少的階層 此處用量皆為重量,算出總重量,屆時可依比例更新用量回主BOM,即bom1

update Cf_inv_bom_2
set Cf_inv_bom_2.sum_qty = t1.c_sum
from (select assy_no,sum(qty) c_sum from Cf_inv_bom_2 group by assy_no) t1
where Cf_inv_bom_2.assy_no = t1.assy_no

–bom1無下階先抓出來

select * from cf_inv_bom_1
where item_no not in (select assy_no from cf_inv_bom_2 )

–再結合有bom1有下階的資料(用量=>被替換子件原用量*(下階子件用量/下階用量之和))

select * from cf_inv_bom_1
where item_no not in (select assy_no from cf_inv_bom_2 )
union all
select T1.assy_no,T2.item_no,CAST(t1.qty*t2.qty/t2.sum_qty AS DECIMAL(10,4) ) d_qty,T1.sum_qty
from cf_inv_bom_2 T2,cf_inv_bom_1 T1
where T2.assy_no=T1.item_no order by 1,2

–由於合併後發現兩階間有共用子件因此多一層group來加總資件用量

select Tu.assy_no,tu.item_no,sum(tu.qty),max(Tu.sum_qty) from
(select [assy_no]
,[item_no]
,[qty]
,[sum_qty] from cf_inv_bom_1
where item_no not in (select assy_no from cf_inv_bom_2 )
union all
select T1.assy_no,T2.item_no,CAST(t1.qty*t2.qty/t2.sum_qty AS DECIMAL(10,4) ) d_qty,T1.sum_qty
from cf_inv_bom_2 T2,cf_inv_bom_1 T1
where T2.assy_no=T1.item_no) as Tu
group by Tu.assy_no,tu.item_no
order by 1,2

Excel VBA 迴圈抓取每三欄轉置成多筆資料 用array寫出

Sub LoopThroughRowsByRefBom()
LastRow = Range("A" & Rows.Count).End(xlUp).Row
FirstRow = 1
i = FirstRow
FirstColumn = 1
Do Until i > LastRow
    LastColumn = Cells(i, Columns.Count).End(xlToLeft).Column
    j = FirstColumn
    Do Until j > LastColumn
        If i Mod 15 = 1 And j Mod 3 = 1 Then
            For k = 0 To 10
               Cells(i + k, j + 2).Value = Cells(i, j)
            Next k
        End If
        j = j + 3
    Loop
    i = i + 15
Loop

 Dim dynArray(1 To 5000, 1 To 4) As String
 i = 1
  k = 1
 Do Until i > LastRow
     LastColumn = Cells(i, Columns.Count).End(xlToLeft).Column
    j = 1
    Do Until j > LastColumn
        If j Mod 3 = 1 And i Mod 15 <= 10 And Not IsEmpty(Cells(i, j + 1).Value) And Cells(i, j + 1).Value > 0 Then
            dynArray(k, 1) = Cells(i, j + 2)
            dynArray(k, 2) = Cells((i \ 15) * 15 + 12, j + 1)
            dynArray(k, 3) = Cells(i, j)
            dynArray(k, 4) = Cells(i, j + 1)
             k = k + 1
        End If
        j = j + 3
    Loop
  i = i + 1
Loop

Dim De1 As Range
Set De1 = Range("AK1")
De1.Resize(UBound(dynArray, 1), UBound(dynArray, 2)).Value = dynArray
End Sub