2012年3月1日 星期四

IGNORE_DUP_KEY = ON

含primary key資料表中,當有新增具重覆鍵資料時,都會有錯誤訊息,因而中斷了整批的交易

若想要自動忽略重覆鍵錯誤.可使用IGNORE_DUP_KEY = ON,如此仍可繼續寫入其餘交易資料忽略此錯誤

用到的情境不多,多虧同事無意間的測試看到這個參數...


--重建資料表
CREATE TABLE dbo.PurchaseOrderDetail
(
    PurchaseOrderID int NOT NULL
        REFERENCES Purchasing.PurchaseOrderHeader(PurchaseOrderID),
    LineNumber smallint NOT NULL,
    ProductID int NULL 
        REFERENCES Production.Product(ProductID),
    UnitPrice money NULL,
    OrderQty smallint NULL,
    ReceivedQty float NULL,
    RejectedQty float NULL,
    DueDate datetime NULL,
    rowguid uniqueidentifier ROWGUIDCOL  NOT NULL
        CONSTRAINT DF_PurchaseOrderDetail_rowguid DEFAULT (newid()),
    ModifiedDate datetime NOT NULL 
        CONSTRAINT DF_PurchaseOrderDetail_ModifiedDate DEFAULT (getdate()),
    LineTotal  AS ((UnitPrice*OrderQty)),
    StockedQty  AS ((ReceivedQty-RejectedQty)),
    CONSTRAINT PK_PurchaseOrderDetail_PurchaseOrderID_LineNumber
               PRIMARY KEY CLUSTERED (PurchaseOrderID, LineNumber)
               WITH (IGNORE_DUP_KEY = OFF)
) 
ON PRIMARY;



--修改索引
USE AdventureWorks2008R2;
GO
ALTER INDEX AK_SalesOrderHeader_SalesOrderNumber ON
    Sales.SalesOrderHeader
SET (
    STATISTICS_NORECOMPUTE = ON,
    IGNORE_DUP_KEY = ON,
    ALLOW_PAGE_LOCKS = ON
    ) ;
GO


參考MSDN上的說明
create table
alter index

2012年1月17日 星期二

呼叫 LoadLibraryEx失敗

因為一個舊系統的需要安裝.net 1.1,所以我在windows 7 enterprise 64X上安裝了.net framework 1.1
 結果造成原本可以瀏覽的.net 4的web site都無法瀏覽了.
出現了這個錯誤

呼叫 LoadLibraryEx (於 ISAPI 篩選器 "c:\Windows\Microsoft.NET\Framework\v4.0.30319\\aspnet_filter.dll" 上) 失敗

Calling LoadLibraryEx on ISAPI filter “C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_filter.dll” failed

尋找一番後, 進行了二件事
1. 在dos 模式下, 切換到C:\Windows\Microsoft.NET\Framework\v4.0.30319 及C:\Windows\Microsoft.NET\Framework64\v4.0.30319 執行 aspnet_regiis -r
2.在iis應用程式集區下,在.net 4.0的應用程式集區下,進到進階設定下,將啟用32位元應用程式設為True

2012年1月16日 星期一

select from sp_help_job

--查看job目前執行狀況
select 
 name
,last_run_date as lastdt
,last_run_time as lasttm
,case last_run_outcome
 when 0 then 'Failed.'
 when 1 then 'Succeeded.'
 when 3 then 'Canceled.'
 when 5 then 'Unknown'
 else 'others' end as lastOutcome
,case current_execution_status
 when 1 then 'Executing.'
 when 2 then 'Waiting for thread.'
 when 3 then 'Between retries.'
 when 4 then 'Idle.'
 when 5 then 'Suspended'
 when 7 then 'Performing completion actions.'
 else 'others.' end as currentStatus
from openrowset ('SQLNCLI', 'Database=msdb;Uid=sa;Pwd=xxxx;','set fmtonly off;exec sp_help_job')
where name like '%yourJobName%'




參考database journal 文章Detecting The State of a SQL Server Agent Job的欄位說明

2012年1月10日 星期二

XXXXX.xls已被修改,你是否要儲存檔案?

每次開啟一個EXCEL檔時,沒做任何修改,關閉這個檔案時,都會提示一個詢問視窗
 XXXXX.xls已被修改,你是否要儲存檔案?

可是明明就沒改啊....

後來採用逐一刪去法, 看看到底是哪個cell在搞怪

原來是有一個cell使用了TODAY()的函數, 造成每次開啟EXCEL時,這個cell都會被重新計算一次.

找到兇手了!

2011年12月22日 星期四

批次刪除檔案

想要在某一目錄包含其子目錄下,快速刪除.xls的檔案
其中,想要排除某一子目錄 不要處理

REM 先將保留的目錄下所有檔案屬性設為唯讀
attrib /s .\reserved\*.xls +r +a > NUL 
REM /s刪除檔案(含子目錄)
del /s .\*.xls 
REM  再將保留的目錄下所有檔案屬性還原
attrib /s .\reserved\*.xls -r -h -s > NUL

2011年11月22日 星期二

PL/SQL Developer 無法登入

PL/SQL Developer類似SSMS 的功能, 連結到oracel db GUI工具

今天安裝了Oracle 10.2 client後 net manager 設定及測試連結都OK

但安裝了PL/SQL Developer 7.0.2.1076 後,卻無法連線,出現以下錯誤

Initialization error 
Could not locate OCI dll

OracleHomeKey: SOFTWARE\ORACLE\KEY_OraClient10g_home1
OracleHomeDir: E:\oracle\product\10.2.0\client_1

參考此篇文章 Could not locate OCI dll Error 

將 E:\oracle\product\10.2.0\client_1\ 下的所有單一檔案 (不包含目錄)複製並覆蓋到 E:\oracle\product\10.2.0\client_1\bin\ 下即可

2011年11月8日 星期二

SQL 2008 R2 Drillthrough slow

環境:
windows 7 enterprise  with sp1 + SQL Server 2008 R2 standard 10.50.2500
or
windows 2008 R2 enterpeise with sp1 + SQL Server 2008 R2 enterprise 10.50.2500
 
SSAS Dimension 25個, 若單人多次或多人一次進行dirllthrough時,此時記憶體使用量急上升,直到用滿了為止,接著就出現以下的錯誤,

同事反覆測試後的結論是, 在10.50.1600時不會有問題,記憶體使用量也不會暴增


TITLE: Microsoft SQL Server Management Studio
------------------------------

The selected action cannot be completed because of the following error.
伺服器: 已因記憶體不足的壓力而取消作業。
伺服器: 已因記憶體不足的壓力而取消作業。
This error may have occurred because the definition for the action is not valid. Verify the definition using the Actions view.

------------------------------
ADDITIONAL INFORMATION:

伺服器: 已因記憶體不足的壓力而取消作業。
伺服器: 已因記憶體不足的壓力而取消作業。 (Microsoft SQL Server 2008 R2 Analysis Services)


反應給MS,最後獲得的回答是在CU6之後會有此問題, 要等SQL Server 2012才會修正. 
目前可提供了一個解決方法
1、 開啟下列的檔案:
C:\Program Files\Microsoft SQL Server\MSAS10_50.Instance Name\OLAP\Config\ msmdsrv.ini
2、 修改下列的值
原本的值:
<SpaceDecomposition>8</SpaceDecomposition>
修改後的值:
<SpaceDecomposition>11</SpaceDecomposition>
3、 重新啟動 SQL Server Analysis Services

測試後,解決了問題. 恭喜大家,歷經一個月的溝通與測試終於解決了...

 

 2022/08/26 後記...

在SSAS 2019上,遇到drillthrough 很慢很慢的問題,同樣地調整這個參數後,健步如飛啊。

IIS 網站無法下載中文檔名檔案因為取消高位元字元

 網址+中文檔案名稱方式下載檔案顯示 404 - 找不到檔案或目錄。 但英數字檔案名稱則可下載。 因為設定GCB IIS,其中1項 將高位元字元預設取消勾選了。 27 TWGCB-04-014-0028 要求篩選與其他限制模組 允許高位元字元 這項原則設定決定查詢...