判斷 SQL Server 版本

DECLARE @ver varchar(2)
SET @ver=LEFT(CONVERT(varchar(20),SERVERPROPERTY(‘ProductVersion’)),CHARINDEX(‘.’,CONVERT(varchar(20),SERVERPROPERTY(‘ProductVersion’)),1)-1)
SELECT
CASE
WHEN @ver=’8′ THEN ‘2000’
WHEN @ver=’9′ THEN ‘2005’
WHEN @ver=’10’ THEN ‘2008’
WHEN @ver=’11’ THEN ‘2011’
END AS ProductVersion,
SERVERPROPERTY(‘ProductLevel’) AS ProductLevel,
SERVERPROPERTY(‘Edition’) AS Edition,
SERVERPROPERTY(‘EngineEdition’) AS EngineEdition;

參考

http://support.microsoft.com/kb/321185

http://msdn.microsoft.com/en-us/library/ms174396.aspx

 

查詢資料庫物件的 Owner

SELECT USER_NAME(ObjectProperty(ID,’ownerid’)),* from sys.sysobjects

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

Google+ photo

You are commenting using your Google+ account. Log Out / 變更 )

連結到 %s

%d 位部落客按了讚: