create table OverTableTest( id int identity(1,1),--ID Val int, --值 typ int, --類型)godeclare @cou intset @cou=1while @cou<50begin insert into OverTableTest select @cou,@cou%5+1 set @cou=@cou+1endgoselect * from
行列倒置是SqlServer中常用的技巧之一,不同於SqlServer2000用case拼接的方式,SqlServer2005提供pivot和unpivot關鍵字來實現這一技巧。一.使用PIVOT進行行列倒置樣本資料庫及測試資料 Code highlighting produced by Actipro CodeHighlighter
1、備份到備份裝置,且做差異備份backup database firenews to backupfirenews with DIFFERENTIAL,noinit,nounload,name=N'fireweb_db',noskip,stats=10,noformat其中,backupfirenews
下面的文章中包含可以下載add-in的地址, 以及一個htm格式的說明檔案. Microsoft SQL Server 2008 Reporting Services Add-in for Microsoft SharePoint Technologieshttp://www.microsoft.com/downloads/details.aspx?familyid=200FD7B5-DB7C-4B8C-A7DC-5EFEE6E19005&displaylang=enMicrosoft
網上較多的使用的方法是將使用identity將資料查詢出來儲存在暫存資料表中,然後從暫存資料表中查詢資料select rownum=identity(int,1,1),id,name into #t from table1 select * from #t但是我所使用的表主鍵已經使用了自增標識,那麼此方法就無法使用了。下面的方法可能會更好的解決Rownum問題:SELECT RowNum = ROW_NUMBER() OVER (ORDER BY t.score desc) ,t.*
這是一道面試題,今天有空把它記下來,以後遇到此類問題作個參考!剛一看到這個題目,估計好多人都會想到關鍵字top,其實這裡用到的關鍵字是partition,好了,先看看錶結構,及資料吧! 接下來看一看partition的功能,執行語句 select c.*,ROW_NUMBER() over (partition by c.ID order by c.Sorce desc) rank from dbo.courcer c結果如下: 到這裡一目瞭然知道最終結果了! View Code
SQL Server之1:全文檢索搜尋(1) 本章介紹在SQL Server 2008 R2 下的全文索引,它能夠對資料中的字元類型列(如varchar、text等類型)進行索引,並通過索引實現全文檢索搜尋查詢。首先對比簡單介紹一下常規索引和全文索引的區別,如:OK,下面我們就利用SQL Server 提供的預存程序來建立一個全文索引,具體步驟為:(1)啟動資料庫的全文處理功能(sp_fulltext_datebase);(2)建立全文檢索目錄(sp_fulltext_catalog);(3)
/*Author: Jiangong SUN*/I've made a web site prototype these days, I've found there are some useful information to share with you about some usual problems about users.1/ How to create a user and give it rights to access a database2/ Once you have
SELECT * FROM sysobjects WHERE (xtype = 'U')SELECT * FROM sysobjects WHERE (xtype = 'U')SELECT * FROM sysobjects WHERE (xtype = 'C')SELECT * FROM sysobjects WHERE (xtype = 'D')SELECT * FROM sysobjects WHERE (xtype = 'F')SELECT * FROM sysobjects