標籤:最近做資料轉移,由於誤操作,在系統資料表master表裡建立了N多表 實在是沒法刪找到以下方法共用一下--指定要刪除的資料庫中的表use mastergodeclare @sql varchar(8000),@TableName varchar(100)begin declare cur cursor for select Name from sysobjects where xtype=‘p‘ and crdate>=‘2015-03-31 10:33:14.6
標籤:轉自:http://blog.csdn.net/xys_777/article/details/5711128--分組取最大最小常用sql--測試環境if OBJECT_ID(‘tb‘) is not null drop table tb;gocreate table tb( col1 int, col2 int, Fcount int)insert into tbselect 11,20,1 union allselect 11,22,1 union
標籤:insert into OPENROWSET(‘Microsoft.ACE.OLEDB.12.0‘,‘Excel 12.0;Database=C:\c.xlsx‘,‘select 欄位1,欄位2 FROM [sheet1$]‘) select 欄位1,欄位2 from table 今天單位一ASP.NET網站,裡面有個功能是匯出資料,發現一匯出就報錯,報錯內容是:SQL Server 阻止了對組件 ‘Ad Hoc
標籤:原文地址:Stairway to SQL Server Indexes: Level 9,Reading Query Plans本文是SQL Server索引進階系列(Stairway to SQL Server Indexes)的一部分。在這個系列中,我們經常會以特定的方式執行特定的查詢。我們引用產生的執行計畫來支援我們的論調。SQL
標籤:---分頁查詢select top 2 *from student where sno not in (select top 2 sno from student) --not in() 屏蔽掉前兩行 在此基礎上再取前兩行--分頁的預存程序 --直接用輸入參數當作表名和列名,無法被識別,先用‘++‘拼接成字串,然後用exec去執行,exec依然會把這個字串當作語句執行create proc fenye1@nowye int ,--當前頁@number
標籤:use Testgoif exists(SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N‘gettime‘) AND type in (N‘FN‘, N‘IF‘, N‘TF‘, N‘FS‘, N‘FT‘))-- 判斷是否存在該自訂函數drop function gettime -- 刪除該自訂函數gocreate function gettime(@t datetime) ---- 建立自訂函數帶參數returns