DECLARE @li_sql_version int set @li_sql_version = convert(int,left(convert(varchar(100), SERVERPROPERTY('productversion')), charindex('.', convert(varchar(100), SERVERPROPERTY('productversion')),1)-1)) if @li_sql_version >8 --SQL >2005 exec(' SELECT db.name as db_name, mf.name as logical_name, mf.physical_name AS current_file_location FROM sys.master_files mf inner join sys.databases db on mf.database_id = db.database_id ') else exec(' --SQL 2000 select db.name as db_name, mf.name as logical_name, mf.filename as current_file_location from master.dbo.sysaltfiles mf inner join master.dbo.sysdatabases db on mf.dbid = db.dbid ')SQL Displaying data/log files location of all databases
2012年5月3日星期四
MSSQL >2000: 列出數據庫及日誌檔位置
頭6句是用來分辨2000還是較新版本.
Labels:
SQL
訂閱:
發佈留言 (Atom)
沒有留言:
發佈留言