I love to research SQL Server Internal and SQL Server Architect. Today I found out the knowledge about Server Message Block, that is useful....
Mirrored Backup and Restore and Split File Backup
Here is a useful knowledge a DBA should know. If we perform backup a large database, we can split it into multiple files and store them in m...
SQLIO Disk Subsystem Benchmark Tool
SQLIO is a tool provided by Microsoft which can also be used to determine the I/O capacity of a given configuration. For more information: h...
Adaptive Index Defrag
Maintaining database is the responsibility of DBA and it is done periodly. But it seems that many DBA do not like to use Maintenance Plan in...
When was the last time your SQL Server database was restored
Here is the answer. The information is stored in the MSDB database. DECLARE @dbname sysname, @days int SET @dbname = NULL --substitute fo...
Check backup file and run DBCC auto
There is nothing to ensure that your backup could be restored unless you really restore it. Here is the tip that we can automate the task ...
Find Temp tables in Tempdb
Find all Temporary tables in Tempdb SELECT * FROM tempdb.INFORMATION_SCHEMA.tables ORDER BY TABLE_NAME Tham khảo: http://www.sqlviet.co...
Will Instant File Initialization Really Help My Databases?
This configuration help the database file growth faster, but it just applies to data file, not log file. Please be noted that after we cha...
sp_AskBrent™ Helps You Troubleshoot Slow SQL Servers.
I kept getting emails and phone calls that said, “The SQL Server is running slow right now, and they told me to ask Brent.” Each time, I’d...
Diagnose database at database level
Here is the script give us I/O statistics in each data/log file SELECT DB_NAME(fs.database_id) AS [Database Name], mf.physical_name, io_st...
Đoạn script liệt kê database file name and path
SELECT DB_NAME([database_id])AS [Database Name], [file_id], name, physical_name, type_desc, state_desc, CONVERT( bigint, size/128.0) AS [To...
Tìm hiểu thông tin về SQL Server Services
SELECT servicename, startup_type_desc, status_desc, last_startup_time, service_account, is_clustered, cluster_nodename FROM sys.dm_server_s...
Đoạn script tìm bad non-clustered index
SELECT OBJECT_NAME(s.[object_id]) AS [Table Name], i.name AS [Index Name], i.index_id,user_updates AS [Total Writes], user_seeks + user_sca...
PAGELATCH_EX waits and heavy inserts
http://blogs.msdn.com/b/blogdoezequiel/archive/2013/05/23/pagelatch-ex-waits-and-heavy-inserts.aspx
Tìm hiểu thêm về transaction log fragmentation
https://www.simple-talk.com/sql/database-administration/sql-server-transaction-log-fragmentation-a-primer/
Why fragmentation transaction log is problematic
SQL Server transaction log files have an internal structure called the Virtual Log File or VLF. When the number of VLFs grow out of control...
Check VLF cho mỗi transaction log file mỗi database
CREATE TABLE #VLF_temp (FileID varchar(3), FileSize numeric(20,0), StartOffset bigint, FSeqNo bigint, S...
Solving SQL Server Database Physical File Fragmentation
Sử dụng 1 tool của Microsoft gọi là Contig để check database file bị phân mảnh, và nếu ta muốn giải phân mảnh, làm cho database offline và g...
Monitor Tempdb space
Đoạn script để monitor tempdb, nếu là dba thì nên cài đặt để được inform mỗi ngày. Dựa vào thông tin này sau một ngày busy của production s...
Hiểu nhầm về Table variable trong SQL Server
Nhiều người nghĩ rằng Table Variable được lưu trên memory, thật ra nó được lưu trong Tempdb. Ta có thể chứng minh điều này bằng cách dùng ...
Finding Count of Logical CPU using T-SQL Script – Identify Virtual Processors
Tìm logical cpu SELECT cpu_countFROM sys.dm_os_sys_info http://blog.sqlauthority.com/2012/02/04/sql-server-finding-count-of-logical-cpu-...
SQL Server Tool: SQLQueryStress
This is a free tool, we use it for creating pressures to SQL Server, and testing Performance. As the screenshot below, I opened 200 sessio...
Không nên shrink the datfabase
Trong ví dụ dưới đây tác giả chứng minh không nên shrink database. http://www.sqlskills.com/blogs/paul/why-you-should-not-shrink-your-data-...
SQL Fragmentation Analyzer: công cụ miễn phí cho SQL Server
Công cụ này giúp ta phân tích và xử lý phân mảnh cho SQL Server, cho 1 table hay toàn bộ database. http://www.idera.com/productssoluti...
18-10-2013
coi lại về query page life execptancy query những query trong cache to tìm poort performacne
check backup history
SELECT TOP 100 s.database_name , m.physical_device_name , CAST ( CAST ( s.backup_size / 1000000 AS INT ) AS VARCHAR ( 14 )) + ' ...
Xem restore history
SELECT * FROM MSDB..RestoreHistory WITH (nolock) WHERE destination_database_name = 'YourDBName' ORDER BY restore_date DESC
Những điều cần biết về transaction log
http://blog.sqlxdetails.com/transaction-log-myths/ Đọc thêm: http://technet.microsoft.com/en-us/library/ms189085(v=sql.105).aspx BACKUP...
1 kinh nghiệm về security
http://blog.sqlxdetails.com/procedure-with-execute-as-login/
Transaction Log truncate vs shrink
http://blog.sqlxdetails.com/transaction-log-truncate-why-it-didnt-shrink-my-log/
Check how many VLFs in Transaction Log File
We can use the following SQL Statement: DBCC LOGINFO Each record represent one VLF 2 means Active, 0 is inactive. Please notice t...
Xử lý 1 suspect database
http://www.sqlskills.com/blogs/paul/creating-detaching-re-attaching-and-fixing-a-suspect-database/
Monitor transaction log
We can monitor the transaction log for all databases in an SQL Server Instance based on the SQL Statement: DBCC SQLPERF (LOGSPACE) Follo...
sysinternal tool to troubleshoot sql server
Có time thì nghiên cứu cái này http://technet.microsoft.com/en-us/sysinternals/bb545046
Check size of each index
SELECT OBJECT_NAME(i.OBJECT_ID) AS TableName, i.name AS IndexName, i.index_id AS IndexID, 8 * SUM(a.used_pages) AS 'Indexsize(KB)...
Tuning transaction log?
The fact that writes are always sequential also means that SQL Server will only ever write to one transaction log file at a time. There is ...
SQL Script liệt kê các Missing Index
Missing index tức là các index không tồn tại trong SQL Server, nhưng có những câu truy vấn nào đó cần những index này, dba phải biết cách lấ...
Dùng extended event để trace page split
http://www.sqlskills.com/blogs/jonathan/tracking-problematic-pages-splits-in-sql-server-2012-extended-events-no-really-this-time/
Ola Hallengren: scripts maintenance database miễn phí cho SQL Server
Trang web này cung cấp một giải pháp SQL Server miễn phí giúp bảo trì database. Đây là một T-SQL script hay giúp maintenance index, sử dụn...
DBCC CHECKDB data purity checks are skipped for master and model
Hôm nay đọc được bài viết, có vẻ như SQL Server tự động thực hiện dbcc checkdb cho các system databse, và có 1 bug là nó sẽ bỏ qua master và...
Dùng Execute as để phân quyền trong SQL Server
http://www.sqlservercentral.com/articles/Execute+AS/71673/ Một lỗi đã gặp khi dùng Execute as http://support.microsoft.com/kb/913423
Trace deadlock on SQL Server
SQL Server xử lý Deadlock như thế nào? Dựa vào 2 tiêu chí: Deadlock Priority Rollback cost Cách tạo Deadlock trong SQL Server Bướ...
Tìm transaction đang mở
Đoạn script tìm những long running transaction đang mở SELECT ST.transaction_id AS TransactionID ,DB_NAME(DT.database_id) AS DatabaseName...
Blitz: Tool dùng khi tiếp quản 1 sql server
Khi ta tiếp quản 1 sql server có nhiều vấn đề tiềm tàng phát sinh, ta phải nhanh chóng có được thông tin của chúng. Nói là tool nhưng thực...
1 tool để đo performance qua các lần tuning
Nếu ta cần tune 1 câu truy vấn, ta có thể phải thử nhiều phương án khác nhau. Có 1 tool tự động log lại và so sánh thông số cho mỗi phương...
Server trace sẽ bị remove ở SQL Server future version
Link kiểm chứng http://technet.microsoft.com/en-us/library/ms190362.aspx
Vài kiến thức về Execution Plan
Nếu ta thấy EP có dùng merge join, và thấy có sort icon, tức là ta phải cân nhắc 2 lựa chọn - Merge join chưa phải là giải pháp tối ưu, v...
Cách sử dụng Server Trace
Set filter trong profiler trước khi tạo Server trace Lưu ý là ta không cần dấu % ở đây Lúc tạo server trace có tổng cộng 5 tham số, tham...
Profiler vs server trace
http://sqlblog.com/blogs/linchi_shea/archive/2007/08/01/trace-profiler-test.aspx Xem thêm cách tóm Nested Stored Procedure với Profiler: ...
SQL Sentry Plan Explorer
Đây là một công cụ để đọc SQL Server Execution plan Cái hay của Sentry Plan Explorer là ta có thể xem chi phí theo IO hay CPU hay cả 2 bằ...
Performance tuning secret
Execution plan - Cách đọc implicit convert từ Execution plan? - Merge join, hash match join, nested loop join Cách viết Query - Set noc...
SSIS - vấn đề với cột Date khi đọc file từ Excel
Trong dự án, có 1 SSIS package đọc file từ Excel. 1. File thứ 1 Khi mở file Excel ra thì tôi thấy nó hiển thị dưới dạng dd/mm/yyyy, cột n...
1 câu hỏi về Truncate table
Truncate We have created following table: CREATE TABLE dbo.T_EMPLOYEE ( EmpNo VARCHAR(20) NOT NULL PRIMARY KEY, EmpName VARCHAR(50), ...
1 câu hỏi về Select count(distinct...) trong SQL Server
create table #temp_test (id int) insert into #temp_test values(1) insert into #temp_test values(NULL) insert into #temp_test values(2) ...
Try...Catch có dùng được trong SQL Server functions??
Try.. Catch.. Can we implement Try/Catch blocks inside Use Defined Functions(UDF)? Choose your answer: Yes No Correct answer: No...
List data type của toàn database
SELECT distinct ty.name FROM sys.tables as t inner join sys.columns AS c on c.object_id = t.object_id inner join sys.types AS ty ON c.u...
Dùng RESOURCE_SEMAPHORE Waittype để chẩn đoán Memory Issues
Có 1 tác giả chia sẻ SQL Server chạy chậm, tìm hiểu các transactions thì thấy hầu hết là wait type RESOURCE_SEMAPHORE. Chứng minh đang có Me...
Tách system object ra 1 filegroup riêng
http://dacosta9.wordpress.com/2009/02/26/sql-server-2008-io-tuning-filegroups/
Checking That Your Max Server Memory Is Effective
How you decide to confi gure Max Server Memory when you build a server (there are many opinions on the matter) isn’t as important as measu...
Tìm hiểu Plan cache trong SQL Server
Đoạn script sau đây sử dụng sys.dm_exec_cached_plans để hiển thị số lượng cached plans và dung lượng tính theo MB: SELECT count(*) AS ...
Chẩn đoán Memory Pressure
Cách 1: Monitoring SQL Server’s buffer pool is a great way to look out for memory pressure, and Performance Monitor provides numerous co...
Using sys.dm_os_ring_buffers To Diagnose Memory Issues in SQL Server
http://blogs.msdn.com/b/mvpawardprogram/archive/2012/06/04/using-sys-dm-os-ring-buffers-to-diagnose-memory-issues-in-sql-server.aspx http:/...