標籤:1.查詢資料庫中的所有資料庫名: SELECT Name FROM Master..SysDatabases ORDER BY Name2.查詢某個資料庫中所有的表名: SELECT Name FROM SysObjects Where XType=‘U‘ ORDER BY Name3.查詢表結構資訊: 1 SELECT (case when a.colorder=1 then d.name else null end) 表名, 2 a.colorder 欄位序號,a.name
標籤:Locking is a major part of every RDBMS and is important to know about. It is a database functionality which without a multi-user environment could not work. The main problem of locking is that in an essence it‘s a logical and not physical problem.
標籤:定義一個自增列,使用delete後,再插入資料,自增列仍按照刪除前的最大值遞增;若使用truncate 後,再插入資料,自增列從頭開始遞增指令碼一(使用delete):create table #test(codes int identity,valuess int)insert into #test(valuess) select 1select * from #test----------------delete from #test------------------insert
標籤: 用慣了使用Entity Framework串連資料庫,本篇就來體驗使用SqlConnection串連資料庫。 開啟Sql Server 2008,建立資料庫,建立如下表: create table Product( Id int identity(1,1) not null primary key, Name nvarchar(50) null, quantity nvarchar(50) null, Price nvarchar(50)
標籤:在上一篇文章也談SQL Server 2008 處理隱式資料類型轉換在執行計畫中的增強 中,我提到了隱式資料類型轉換增加對於資料分布很不平均的表,評估的資料行數與實際值有很大出入的問題,進一步測試之後,我發現這種評估不準確性應該確實與猜測的一樣,它使用了變數的評估方式。通過如下測實驗證,首先建立資料分布不平均的測試表。USE tempdbGOCREATE TABLE _t( c varchar(50));CREATE INDEX IX_c ON _t( c );GO-- 加入 100
標籤: 團隊合作設計一套系統資料模型,建立了PDM後,Table、View、Store Procedure等都建立好了,且建立了多個Schema方便管理這些資料庫物件,但Table、view、Column等對象有Comment時(用來在團隊不同成員間共用描述資訊) 產生資料庫時會得到一個提示"不支援擴充屬性,或對象不存在",分析發現異常在類似以下語句: if exists(select 1 from