if not object_id('Class') is null drop table ClassGoCreate table Class([Student] nvarchar(2),[數學] int,[物理] int,[英語] int,[語文] int)Insert Classselect N'李四',77,85,65,65 union allselect N'張三',87,90,82,78Go--2000:動態:declare @s nvarchar(4000)select
-- 使用函數的方法:--建立 示範環境if object_id('tb_bookInfo') is not null drop table tb_bookInfogocreate table tb_bookInfo(number int,name varchar(10),type int)insert tb_bookInfoselect 1 ,'n1', 6 union allselect 2 ,'n2', 3if object_id('tb_bookType') is not null
以下以資料庫t1和test為例。1.複製表結構及資料select * into 資料庫名.dbo.表名 from 源表(全部資料)如:select * into t1.dbo.YS1 from test.dbo.DXYS ,此句執行的結果是把test資料庫中的DXYS表及資料複製一份到t1資料庫中,並命名為YS1,其中t1中的YS1表是建立的。2.完全複製 insert into 資料庫1.dbo.表1 select * from 資料庫2.表2如:insert into
預存程序、儲存函數的加密:WITH ENCRYPTION <!--[if !supportLineBreakNewLine]--> <!--[endif]--> CREATE procedure dbo.sp_XML_main @table_name nvarchar(260)=’’, @dirname nvarchar(20)=’’ WITH ENCRYPTION as begin .................... end go 預存程序、儲存函數的解密 (
在SQL 2000 和 2005下 的不同 方法 先說 2000下的 create table #temp1(ID int not null ,code varchar(10) not nullprimary key(ID,Code) )insert into #temp1(ID,code) values(1,'01')insert into #temp1(ID,code) values(3,'01')insert into #temp1(ID,code) values(100,'01')
private static string Cleanse(string InputString) {//過濾掉 And AND aNd 等包含And的字元 MatchCollection ms = Regex.Matches(InputString, " (a|A)+(n|N)+(d|D)+ "); foreach(Match m in ms) { InputString =
下面就以一個簡單的例子來示範如何用 C# 編寫擴充預存程序。首先,我們建立一個簡單的C#類庫檔案://C# file: Csserver.cs using System; using System.Runtime.InteropServices; using System.Reflection; using System.Runtime.CompilerServices; [assembly: AssemblyTitle("CSServer")] [assembly:
有關SQLServer記憶體問題(收藏)-資料庫專欄,SQL Server 最近在做一個流量統計的功能,資料量在千成級,每次統計時,SQL記憶體佔用都會比較大,統計的預存程序執行過後,發現SQL的記憶體使用量也不會釋放,見有些達人說,這是SQL的一個機制,用於提升下次訪問的效率,也許吧,在尋找解決方案的過程中,發現了下面這個文章,挺全,備案;http://www.richsearch.com/search/search.aspx?page=1&s1=%2b%e5%86%85%e5%ad%
max degree of parallelism說明:http://msdn.microsoft.com/zh-cn/library/ms181007.aspx 當 SQL Server 在具有多個微處理器或 CPU 的電腦上運行時,它將為每個並行計劃執行檢測最佳並行度(即運行一個語句所使用的處理器數)。您可以使用 max degree of parallelism 選項來限制並行計劃執行時所用的處理器數。如果預設值為 0,則使用所有可用的處理器。將 max degree of
對SQL Server 2008 進行Mirror的基本配置及安裝。準備工作1. Principal 與Mirror 以及 Witness 三台執行個體都安裝為相同版本,目前是到SQL Server 2008 SP1。2. 需要有一個域帳戶分別添加到 三台資料庫執行個體所在的Server 的 Administrators組、以及SQL Server 相關的組中; 由於具體的組的功能不清楚,因此建議所有組都添加該域帳戶,確保許可權運行正常。3. 將第二步中的域帳戶設定為SQL Server 服務,