วันพุธที่ 26 กันยายน พ.ศ. 2555

Excel & OLAP Pivot table


การสร้าง Pivot table จาก OLAP ใน MS Excel

1. Connection ที่สร้างใหม่จะเป็นไฟล์อยู่ในเครื่อง Computer นั้นๆ
2. Connection ที่สร้างไว้แล้วสามารถ Reuse ได้
3. ใน Excel work book สามารถอ้างถึง Connection ในเครื่อง Computer ที่สร้างไว้ได้
  3.1 โดย default , Excel จะ Copy connection string จาก Connection file ในเครื่อง computer มาไว้ใน Work Book
  3.2 เราสามารถเลือก Option ให้ Excel link connection จาก Connection file ในเครื่อง Computer ได้
  3.3 โดย default , Excel จะไม่ save password ไว้ใน Connection string ที่ Copy มาไว้ใน Workbook ต้องคลิ๊กเลือก Save passord เอง

4. Connection ใน Excel work book สามารถถูกอ้างถึงจาก Pivot table หลาย pivot ได้
   4.1 การ Refresh pivot table ใดๆ จะทำการ Refresh Connection ที่ pivot table นั้น Refer ไปถึง ไม่ใช่แค่เพียง Refresh เฉพาะ Pivot table นั้นๆ
   4.2 หาก 1 Connection มี Pivot table หลาย pivot อ้างถึง   การ Refresh connection นั้นๆ จะทำการ Refresh ทุก Pivot table ที่อ้างถึง Connection ที่ Refresh
   4.3 ดังนั้น การที่เราเข้าใจว่าจะ Refresh เฉพาะ Pivot table ที่ต้องการนั้นไม่จริง  เพราะหาก Connection ที่ Pivot Refer มี Pivot table อื่นๆอ้างถึงอยู่ด้วย  ทุก Pivot table ที่อ้างถึง Connection นั้นจะถูก Refresh ทั้งหมด

5. ข้อแนะนำสำหรับการสร้าง Pivot table ใน Work book
   5.1 หาก Pivot table แต่ละ pivot ที่สร้างขึ้น ใช้เวลานานในการ Refresh Data ควรสร้าง Connection ใน Work book แยกกันเพราะเวลา Refresh จะได้ไม่กระทบกับ Pivot อื่นๆ
   5.2 Pivot table ที่สามารถ Refresh Data ได้รวดเร็วสามารถใช้ Connection เดียวกันได้



SSAS Cube processing tips.

วิธีการประหยัดเวลาในการ Process OLAP Cube ที่มีปริมาณข้อมูลเยอะมากๆ
ในกรณีที่อยู่ระหว่างการแก้ไข หรือตรวจสอบความถูกต้องของข้อมูลใน CUBE
การ Process FULL เป็นตัวเลือกที่ไม่ดีสำหรับกรณีใดๆที่มีข้อมูลเยอะมากๆ
เนื่องจากหากมี Error ใดๆ จำให้การ Process failed ทั้งหมด
ดังนั้นคำแนะนำคือ ทำการ Process Object ตามลำดับขั้นดังนี้

1 Process Full Dimension 
เพื่อตรวจสอบความถูกต้องของ Dimension ต่างๆ ทั้งข้อมูลใน Dimension และ Hierarchy รวมถึงการ Set Attribute relationship

2 Process Cube Structure
เพื่อทำการ Build structure ทั้งหมดของ CUBE ซึ่งการ Process นี้จะทำการล้างข้อมูลทั้งหมดที่มี (หาก Set storage mode = MOLAP) แต่จะทำให้สามารถ Browse cube ได้เหมือนกับ Process Full เพียงแต่ไม่มีข้อมูลแสดงเท่านั้นเอง

3 Process Data 
สามารถ Process Measure Group และ Partition ภายใต้ Measure Group
เพื่อทำการ Add ข้อมูลเข้าระบบ ทั้งนี้ ควรทดสอบ Process data ใน Partition บางส่วนก่อนเพื่อตรวจสอบความถูกต้องของข้อมูล เพราะหากมีการ Re-Design dimension และทำ Attribute relation ship ผิดใน Dimension design จะส่งผลกับข้อมูลผิดตามไปด้วย

4 Process Index
เพื่อ Process aggregation ของ CUBE ซึ่งส่วนนี้ขึ้นอยู่กับการ Design aggregate ใน Cube partition

โดยขั้นตอนลำดับขั้นที่กล่าวมาเป็นวิธีการที่ช่วยลดเวลาในการ Process Cube เพื่อตรวจสอบ
หรือสามารถ apply ได้ในหลายกรณีครับ


วันอังคารที่ 21 สิงหาคม พ.ศ. 2555

sql server update record , percent complete

กรณี Update ข้อมูลจำนวนมาก
หากต้องการรู้ว่า การ update นั้น เสร็จไปแล้วกี่เปอร์เซ็นต์

SELECT * FROM sys.dm_exec_requests WHERE session_id = 68
See column percent_complete




Credit
http://www.mssqltips.com/sqlservertip/1338/finding-a-sql-server-process-percentage-complete-with-dmvs/

วันอังคารที่ 10 กรกฎาคม พ.ศ. 2555

SQL Server list Database file name


select d.name as db_name, f.name as file_name, f.filename as logical_filename
from sysaltfiles f
inner join sysdatabases d
on (f.dbid = d.dbid)
order by 1,2


Restart OLAP Service from SSIS package

Reference from http://businessintelligencechronicles.blogspot.com/2009/02/using-ssis-script-task-to-executing.html


Using script task to connect remote server to stop & start mssqlserverOLAPService
Basicly we know command to stop and start olap service via command prompt.

Start -->Run command
Net stop mssqlserverOLAPService   <---- Command to stop
Net start mssqlserverOLAPService   <---- Command to start

In the example he remote to run Calc.exe via Command variable
In my case I create two string Command (Command1 , Command2)
Set Command1 = Net stop mssqlserverOLAPService
Set Command2 = Net start mssqlserverOLAPService


And then seperate  commands into 2 script tasks
1 = Script for stop
2 = Script for start

**Remark If  you SSIS version is 2008 You no need to change anythings except your command.
If you using  SSIS 2005 you need to change a little bit command
from Dts.TaskResult = ScriptResults.Success to be Dts.TaskResult = Dts.result.Success
That's it.



That's work perfectly!!!
Thanks