一段trigger codes例子: 插入、刪除和更新的觸發器代碼:Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->-- dbo.trGroups.SQL IF EXISTS ( SELECT * FROM sysobjects WHERE name = 'trGroups' AND type = 'TR')BEGIN
同樣的命題在SQL Server 2005中,微軟發布了一個報表,可以直接查看,但是這個報表不能用於SQL Server 2000。 於是我就寫了下面這幾句話,可以返回同樣的結果。 create table tmp (name varchar(50),rows int,reserved varchar(50), data varchar(50),index_size varchar(50),unused varchar(50)) insert into tmp
Introductionsp_who2 is a well known utility that shows what spids are currently executing. However the information it shows is relatively limited. For example, it only shows the type of command executing as SELECT, DELETE etc, with no reference to
Deadlocking occurs when two user processes have locks on separate objects and each process is trying to acquire a lock on the object that the other process has. When this happens, SQL Server identifies the problem and ends the deadlock by
在SQL Server中儲存方式主要分為2大類 緩衝和池。都是用來臨時存放資料的,到底有什麼不同。一直很惱人。有幸看到一位大牛的部落格,截取了其中講述cache 和 pool的不同點。Before we jump into further description of stores I would like to explain a difference between meanings of caches and pools. In SQLOS's world, cache is a
SQL Server中除數為“0”時候的處理 在SQL Server中進行運輸的時候,經常會可能出現除數為0的時候,這個時候該怎麼處理呢? 在遇到這樣的情況啊,解決的版本就是不能讓這個運算執行,在除法運算執行之前預先判斷做出動作。這裡我們可以使用一個CASE語句進行判斷,如果不適合運算就做其它事情。代碼如下Code highlighting produced by Actipro CodeHighlighter
--列出SQL Server執行個體中的資料庫sp_databases--返回SQL Server、資料庫網關或基礎資料來源的特性名和匹配值的列表sp_server_info--返回當前環境中的預存程序列表sp_stored_procedures--返回預存程序文本sp_helptext +儲存名--返回當前環境下可查詢的對象的列表(任何可出現在 FROM 子句中的對象)sp_tablesselect * from sysobjects---添加或更改SQL
兩種實現分頁的sql語句第一種,是我之前經常用的.not in select top 2 * from xy_role where id not in (select top 4 id from xy_role) 其中 '2' 代表這每頁顯示的資訊條數, '4' : 比如頁面上的當前頁是3頁,就是(3-1)*(每個條數)記得如果要排序的話在子查詢中排序和篩選條件 第二種:用sqlserver2005以上版本中的函數row_number()select top 2 * from (select *