首先use [資料庫名稱];exec sp_helpfile;使用sp_helpfile查詢可知道log 檔案的邏輯名稱,然後就可以利用DBCC來減小LOG檔案BACKUP LOG [資料庫名] WITH TRUNCATE_ONLYdbcc shrinkfile ([log檔案的邏輯名稱],1)這個方法在MS SQL Server 2008 以及MS SQL Server 2008 R2中不再適用,會提示:TRUNCATE_ONLY is not a valid BACKUP
問:怎樣才能將XML檔案匯入SQL Server 2000? 答:將XML檔案匯入SQL Server有若干種方法,這裡提供其中的3種: 大容量裝載COM介面。如果需要將文檔的實體和屬性析取到關係表中,最快的方法就是使用SQL Server 2000 Extensible Markup Language 3.0 Service Pack 1(SQLXML 3.0 SP1)提供的大容量裝載COM介面。大容量狀態COM介面包含在SQLXML 3.0 SP1的免費下載中。
複製代碼 代碼如下:-判斷某些欄位是否為空白 --case select case when '欄位名' is null then '\N' else convert(varchar(20),'欄位名') end as 'NewName' select case when null is null then '\N' else convert(varchar(20),null) end as 'NewName' --SQL Server 2005:coalesce select
複製代碼 代碼如下:--會員表 if object_id('userinfo','u') is not null drop table userinfo go create table userinfo(userid int primary key,user_tegral int,level int) insert into userinfo select 1,0,0 go --會員等級表 if object_id('userlevel','u') is not null drop table
複製代碼 代碼如下:--方式一 if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[USP_ProcedureWithTransaction_Demo]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) drop procedure [dbo].[USP_ProcedureWithTransaction_Demo] GO -- ====================
複製代碼 代碼如下:create trigger TR_MasterTable_Update on MasterTable after update as if update ([Type])--當Type欄位被更新時,才會觸發此觸發器 insert into MasterLogTable select Id ,(Case [Type] when 1 then 'Type1' when 2 then 'Type2' when 3 then 'Type3' when 4 then 'Type4'