Few days back when I was working on small query I come across a situation in which I have to select top few records based on the grouping of some column. 501 more words
Tags » SQL Query
This query can be used to analyze how the databases are backed up!
-- Recent Backup Information SELECT top 100 physical_device_name, backup_start_date, backup_finish_date, backup_size/1024.0 AS BackupSizeKB FROM msdb.dbo.backupset b JOIN msdb.dbo.backupmediafamily m ON b.media_set_id = m.media_set_id --where database_name = 'your BName' ORDER BY backup_finish_date DESC --
How to Calculate Age though Sql?
MyTableName:- field is Id, Name, DateOfBirth.
Select CONVERT(int,ROUND(DATEDIFF(hour,DateOfBirth,GETDATE())/8766.0,0)) AS AgeYearsIntRound from dbo._ABEntity1
Select CONVERT(int,ROUND(DATEDIFF(day,DateOfBirth,GETDATE())/369,0)) AS AgeYearsIntRound from dbo._ABEntity1… 23 more words