1.EXEC sp_databases database name on server.
2.SELECT DB_NAME() AS DataBaseName current database name.
3.EXEC sp_MSForEachDB 'Print ''?'''
4.EXEC sp_MSForEachDB 'SELECT ''?'' AS DatabaseName'
5.SELECT name,crdate FROM master..sysdatabases with created date
6.DECLARE @sqlString NVARCHAR(max)
DECLARE @union NVARCHAR(max)
SET @sqlString = ''
SET @union = ''
DECLARE @name nvarchar(50);
DECLARE crs CURSOR FOR
SELECT Name FROM sys.databases WHERE state = 0
OPEN crs
FETCH NEXT FROM crs INTO @name
WHILE @@FETCH_STATUS = 0
BEGIN
SET @sqlString = @sqlString + @union
SET @sqlString = @sqlString + '
SELECT
TOP 1
''' + @name + ''' as DBName, modify_date
FROM
[' + @name + '].sys.tables'
SET @union = ' UNION '
FETCH NEXT FROM crs INTO @name
END
SET @sqlString = @sqlString + ' ORDER BY DBName ASC'
CLOSE crs;
DEALLOCATE crs;
EXEC(@sqlString)
7.SELECT name,crdate,category,cmptlevel,filename,mode,reserved,sid,status,version FROM master..sysdatabases
No comments :
Post a Comment