顯示具有 MSSQL 標籤的文章。 顯示所有文章
顯示具有 MSSQL 標籤的文章。 顯示所有文章

2026/06/01

MS SQL 維護計劃 備份到NAS共用資料夾

環境:

AD

NAS

MS SQL

異常狀況:

MS SQL 維護計劃 在設定DB備份的路徑,不能指定到NAS上的共用資料夾。

解決過程:

維護計劃在備份時,執行的身份通常是預設的一個系統服務帳號,可以到"服務"去查。

因為沒辦法在NAS上的共用資料夾上指派存取權限給這個帳號。

所以要換個方法

1.先在AD建立一個群組,然後把MS SQL這台主機的電腦帳號,加到這個群組。

2.接著在NAS上的共用資料夾,指派AD群組有修改權限。

這樣就完成了,備份時,這台主機就直接有權限讀寫,不會被SQL服務執行的身份給影響。


Environment:

Active Directory (AD)
NAS
Microsoft SQL Server

Issue:

When configuring a database backup destination in an MS SQL Server Maintenance Plan, the backup cannot be written directly to a shared folder on a NAS.

Resolution:

When a Maintenance Plan runs, it typically executes under the security context of a SQL Server service account (which can be identified in Services).

Since it is often not possible to assign permissions on the NAS shared folder directly to this service account, the following approach can be used:

  1. Create a new Active Directory security group.
  2. Add the computer account of the SQL Server to this AD group.
  3. On the NAS shared folder, grant the AD group Modify permissions.

With this configuration, the SQL Server host can access the shared folder using its computer account permissions, allowing the Maintenance Plan to read from and write to the NAS share without being affected by the specific SQL Server service account being used.

2026/02/25

SQL management tool連線時出現錯誤:此憑證鏈結是由不受信任的授權單位發出的

 

環境:

MS SQL2022


異常狀況:

SQL management tool連線時出現錯誤:此憑證鏈結是由不受信任的授權單位發出的


解決過程:

錯誤訊息「此憑證鏈結是由不受信任的授權單位發出的」是因為 SQL Server 2022 預設強制執行加密連線。

勾選下面的「信任伺服器憑證」選項,即可正常登入。




Environment:

MS SQL Server 2022

Issue:

When connecting using the SQL management tool, the following error appears:
“The certificate chain was issued by an authority that is not trusted.”

Resolution:

This error occurs because SQL Server 2022 enforces encrypted connections by default.

Enable the “Trust Server Certificate” option in the connection settings, and then you will be able to log in normally.



2021/05/03

MSSQL2019 查詢目前版本



廠商協助裝好MSSQL後,要確認到底是裝什麼版本,序號有沒有啟用,可以直接下簡單的指令去查。
在cmd底下執行"sqlcmd"
然後再執行
select @@version
go
就會顯示當前的版本,如果有evaluation,就是表示是試用版,沒啟動。
 

MS SQL 2019大量授權序號找不到

 公司買了WINDOWS SERVER & MS SQL2019,然後就上到大量授權的網站要去找序號進行產品的啟用。

兩個產品的資訊都有,但序號的部分,只有SERVER的序號,沒有SQL的序號,問了客服才知道。

序號是在安裝包裡面就有了,所以只要直接在網站上下載安裝包,安裝時就會看到序號已經在裡面了。

2020/10/08

Backup exec 做SQL的增量備份,容量爆增

 SQL的資料庫平常有用Backup exec做完整跟差異備份。

想要每天在多做一個增量備份,如果有異常做資料還原,可以減少遺失的資料。

但增量一做下去,產生的備份檔案居然超級大,差異備份每天才不到10G,一個增量居然就快70G.。後來看到這篇文章 https://www.itread01.com/content/1514883521.html,原來跟SQL主機是架esxi上面有關係。

如果想改善,就要去調整esxi上虛擬機的ctkEnabled 參數,細節就自己去看文章吧。

2012/04/02

MSSQL 中文字串變問號????

在MSSQL資料表的欄位裡面輸入中文的字串後,顯示出來的卻是問號,是因為SQL的版本是英文的,所以必須在輸入的值前面加一個"N"。
範例 :

UPDATE tablename
SET xxx = N'中文測試'
WHERE yyy = 4273

MSSQL 移除空字串旁邊的空格 與 資料集下拉選單的設定


ltrim : 移除字串左邊的空格
rtrim : 移除字串左邊的空格
union all select 'ALL' : 用來做資料集的設定,讓下拉選單可以有"全選"的選項。

範例
若Waveform欄位是空值,就轉成空字串。欄位裡的字串要移除左右兩邊的空格。
select 'ALL'才會讓下拉選單有"ALL"選項可選。
select distinct ltrim(rtrim(ISNULL(Waveform,'')))
FROM Salse_Ans_Main
union all
select 'ALL'
order by 1

而主要的程式條件的語法則是
where Waveform = @Waveform or  @Waveform = 'ALL'