Tags » SQL Query

The Power of Apply operator

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

SQL Query

SQL and HiveQL query examples

Well, we know that HiveQL is very similar to SQL. The detailed Hive Language Manual describes all the important functions and semantics that are used in Hive. 56 more words

Marketeng

TSQL to start a SQL job and check all running jobs


-- TSQL command to start a SQL job with deault settigns 
EXEC msdb..sp_start_job @job_name = 'JobName'

-- Check all running jobs 
exec msdb.dbo.sp_help_job @execution_status=1 

--
SQL

Python: Accessing a SQL database

If you really want to do data work, you need to be able to connect to a database. In this example I will show you how to connect to and query data from MS SQL Server with the AdventureWorks2012 database installed. 249 more words

Python

SQL Query to check when databases were backedup

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
--
SQL

SQL: Aggregates, Group By, and Having

The Where clause is great. It helps you filter out items from a table, leaving only the records you want. But sometimes you are not looking for the actual records. 196 more words

MS SQL Server

Calculate Age in Years through Sql

How to Calculate Age though Sql?
Sol:

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

Interview Question