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 很慢很慢的問題,同樣地調整這個參數後,健步如飛啊。

2011年10月29日 星期六

四捨五入不進位??


人客反應一個四捨五入到小數二位的問題...
我沒什麼頭緒要怎麼解決, 但在不小心中發現一個方法,暫時可以解決四捨五入不進位的問題
這是sql server 的float bug嗎, 還是本來就這樣??

二組數字分別是1.055, 1.1243,型態是float
依四捨五入到小數第二位的話,  結果應該是  c1 =  1.06  c2= 1.12
但結果卻不如人意,而且只有當此float 刪好只有到小數第三位時,欲四捨五入進位到小數二位才會有問題


先reproduce一下狀況..
declare @tab table (c1 float,c2 float)
insert into @tab
select 1.055, 1.1243

select 
c1,c2
,cast(c1 as decimal(5,2)) as r1,cast(c2 as decimal(5,2)) as r2
,cast(c1 + 0.001 as decimal(5,2)) as t1,cast(c2 + 0.001 as decimal(5,2)) as t2
,cast(c1 + 0.0001 as decimal(5,2)) as s1,cast(c2 + 0.0001 as decimal(5,2)) as s2
 from @tab

但結果如下

c1 c2 r1 r2 t1 t2 s1 s2
1.055 1.124 1.05 1.12 1.06 1.13 1.06 1.12

有趣的是, 1.124 + 0.001 =  1.125 , 轉成decimal(5,2)後,又很精準的四捨五入了, 但結果是不對的....


所以再做下列測試
如果c1為1.0551 又或者將型態改成decimal(5,4)  則結果是正確的

declare @tab table (c1 float,c2 float)
insert into @tab
select 1.0551, 1.124

select  
c1,c2
,cast(c1 as decimal(5,2)) as r1,cast(c2 as decimal(5,2)) as r2
,cast(c1 + 0.001 as decimal(5,2)) as t1,cast(c2 + 0.001 as decimal(5,2)) as t2
,cast(c1 + 0.0001 as decimal(5,2)) as s1,cast(c2 + 0.0001 as decimal(5,2)) as s2
 from @tab

c1 c2 r1 r2 t1 t2 s1 s2
1.0551 1.124 1.06 1.12 1.06 1.13 1.06 1.12



declare @tab table (c1 decimal(5,4),c2 decimal(5,4))
insert into @tab
select 1.055, 1.124

select  
c1,c2
,cast(c1 as decimal(5,2)) as r1,cast(c2 as decimal(5,2)) as r2
,cast(c1 + 0.001 as decimal(5,2)) as t1,cast(c2 + 0.001 as decimal(5,2)) as t2
,cast(c1 + 0.0001 as decimal(5,2)) as s1,cast(c2 + 0.0001 as decimal(5,2)) as s2
 from @tab

c1 c2 r1 r2 t1 t2 s1 s2
1.055 1.124 1.06 1.12 1.06 1.13 1.06 1.12

將小數點變成四位後,四捨五入到小數二位就對了

再來一個測試
declare @tab table  (c1 float,c2 float)
 insert into @tab
select 1.055, 1.124

select  
c1,c2
,cast(c1+0.000 as decimal(5,2)) as r1,cast(c2 as decimal(5,2)) as r2
,cast(c1 + 0.001 as decimal(5,2)) as t1,cast(c2 + 0.001 as decimal(5,2)) as t2
,cast(c1 + 0.0001 as decimal(5,2)) as s1,cast(c2 + 0.0001 as decimal(5,2)) as s2
 from @tab


c1 c2 r1 r2 t1 t2 s1 s2
1.055 1.124 1.05 1.12 1.06 1.13 1.06 1.12

加上0.000是沒有用的...

結論:
1.float使用真的要小心謹慎,不是那麼精準
2.四捨五入到小數二位, 則先加0.0001變成有小數四位後,再進行四捨五入

大家有看懂嗎???


天啊..我把SQL SERVER 的唯一帳號密碼改到忘了

SQL SERVER  GBC其中一項規定就是帳號密碼原則要符合GCB規定,所以設定上就調整成 Enforce password policy Enforce password expiration 今天去維護時,打開SSMS 連線後,彈出來密碼到期要更改,於是乎就改了密碼,然後...