sql server
Retrieve useful information from SQL Server
Today we will see how can we retrieve various information from Microsoft SQL Server using SQL queries. Get all users: SELECT * FROM sys.server_principals; Get database size: USE master GO EXEC sp_spaceused Get user privilleges for current database: USE master GO SELECT SYSOBJECTS.name AS ‘objectname’, SYSUSERS.name AS ‘username’ , Action = CASE SYSPROTECTS.action [...]
Backup SQL Server Database
To create a Full Database Backup using transact sql is simple. The following sql code does the trick: USE database_name; GO BACKUP DATABASE database_name TO DISK = ‘D:\DatabaseBackups\database_name.bak’ WITH FORMAT, MEDIANAME = ‘D_Backups’, NAME = ‘Full Backup of database_name‘; GO