msSQL Session running on database
To see witch session id, that run command against a database, you can run this:
Kenneth Qvistgaard Dalbjerg, IT Konsulent i århus
To see witch session id, that run command against a database, you can run this:
How fast is data leving the cache, when it not access again. With this query, you can see how fast data will get expire, and overwritten by new data in the cache. Witch the...
With this query, you can see whitch database that is using most memory
Whit this code, you can see how much of query in percent at this moment is reading from the cache/buffer.
Run this command to see if any database on the SQL Server is using enterprise features
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
IF OBJECT_ID('tempdb.dbo.##enterprise_features') IS NOT NULL DROP TABLE ##enterprise_features CREATE TABLE ##enterprise_features ( dbname SYSNAME, feature_name VARCHAR(100), feature_id INT ) EXEC sp_msforeachdb N' USE [?] IF (SELECT COUNT(*) FROM sys.dm_db_persisted_sku_features) >0 BEGIN INSERT INTO ##enterprise_features SELECT dbname=DB_NAME(),feature_name,feature_id FROM sys.dm_db_persisted_sku_features END ' SELECT * FROM ##enterprise_features |
If you got an error about compression, when trying to attach the database from an enterprise version to a standard version. You will have to attach the database to an enterprise database, and remove...
WIth this command you can see witch user that have SysAdmins access.
1 2 3 4 |
SELECT name,type_desc,is_disabled FROM master.sys.server_principals WHERE IS_SRVROLEMEMBER ('sysadmin',name) = 1 ORDER BY name |
To show all MSSQL databases except the normal system databases.
1 |
select * from sys.databases WHERE name NOT IN ('master', 'tempdb', 'model', 'msdb'); |
To get a list of the databases files, and the current disk size in MB, and the Free Space in MB in each fil, you can use this commands
1 2 3 4 5 6 7 |
USE [DATABASE_NAME] SELECT DB_NAME() AS DbName, name AS FileName, size/128.0 AS CurrentSizeMB, size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS INT)/128.0 AS FreeSpaceMB FROM sys.database_files; |
If you need a...
USE [TestDb] GO ALTER DATABASE [TestDb] SET RECOVERY SIMPLE WITH NO_WAIT DBCC SHRINKFILE([TestDb_Log], 1) ALTER DATABASE [TestDb] SET RECOVERY FULL WITH NO_WAIT GO Where TestDB, is the database name, and TestDB_Log is the SQL Log file name.
Sidste kommentar