This script permit executes the sp_updatestats in all databases at same time.First I create the stored procedure above in an admin database, for sample I create one database with ADMIN name where I put all administration objects create for me. You
You may find yourself in a position where you need to look at what jobs have been running over a specifiedperiod of time. SQL Server has a stored procedure sphelpjob that will allow you to look at the jobs and what their status is currently, but
Whenever SQL Server is restarted, it creates a new error log. If theserver stays up for a while, this can make for a very large error log. I create a job that runs on a daily or weekly basis that executes the sp_cycle_errorlog stored procedure in
原文為Recommended actions for corrupt or suspect databases 概述資料庫掛起和損壞是很少見的,但是卻有可能發生,主要是因為致命的硬體錯誤或者操作失誤,如刪掉記錄檔 更多資訊下面列出的要點的前提你要有各種損壞的或掛起資料庫(廢話),本文受到到一些SQLSERVER MVP同仁和SQLSERVER Team Dev的協助, 方法1.確保你有備份策略,及時的從硬體錯誤中恢複,建議在大多數情況下備份你的資料庫和記錄檔 2.如果可以的話,運行下 DBCC
Make sure each maintenance job has an output file in a standarddirectory.In the advanced tab under the job steps create an output file. This willallow you to see the full description of the job execution. There isnothing more annoying than not being
有一個通常的誤解,覺得應該把選擇性高的欄位放在最前面,這通常只是針對一個欄位的索引,對於複合式索引,常常要把做等式運算的欄位放在最前面,看看測試USE AdventureWorksGOCREATE TABLE demo1 ( id INT identity(1,1) PRIMARY KEY, gender char(1) NOT NULL , age int NOT NULL, DESCRIPTION varchar(1000) default(replicate(
常遇到根據分隔字元來拆分字串的,總結三種方法:1.使用union all 方法代碼Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->--使用union all 方法--思路是組裝成select語句的聯合[SELECT '張三' union all select '李四' union all select '王五']DECLARE @str
今天在最佳化語句是發現了很有意思的現象,平常的SELECT語句,都加上了NOLOCK提示,提高並發度減少阻塞,速度比沒有加NOLOCK能明顯感覺快,今天的主要的兩個表一個為24G,另一個為34G,行數為2千多萬行。主要資源消耗在如下的SQL語句: select orderID from bigtable(nolock)binner join from biggertable(nolock) bt on b.orderid=bt.orderidwhere tb.orderDate
ad hoc 一般都說是即席查詢,當到底什麼是即席查詢,也沒有說清楚,讓人一頭霧水,在wikipedia上的解釋如下: ad hoc 允許終端使用者自己去建立特定的、自訂的查詢請求。通常是通過一個方便使用的圖形介面來進行資料查詢而無需使用者對 SQL 或者資料庫結構描述有深入的瞭解。 在stackOverflow上的解釋如下:Ad hocis latin for "for this purpose". You might call it an "on the fly" query, or a "