SQL Code Snippets

08 February, 2016   

A type of replacement function within the SELECT statement.

Oracle 10G has enhanced the flashback feature further and has turned it into a much more powerful feature by introducing a number of additional function. Some of the more common ones are discussed here. - Flashback Table - Flashback Drop - Flashback Database

04 February, 2015   

Finds database users with deadly system privileges assigned to them.

25 October, 2014   

DBCA is what you need to create a test database in only 5 mins.

07 August, 2014   

All hints except /*+ rule */ cause the CBO to be used. Therefore, it is good practise to analyze the underlying tables if hints are used (or the query is fully hinted.

07 April, 2014   

Adding a linked server to MSSQL account - particularly a MYSQL server

15 January, 2014   

It will fetch and process every record in a cursor.

An example of finding duplicate values in a table column

Using a stored procedure as the source in an OLE_DB Source for SSIS, the package can’t detect the output of the stored proc.

08 May, 2013   

Shred attribute values out of an XML Variable in SQL 2008

Query to find the most recent logins for a particular user

To produce a random character from a specific list of characters (for example 'x', 'y' or 'z')

16 January, 2013   

How to calculate age in years and months

12 January, 2013   

Search the source code of all stored procedures.

12 January, 2013   

Find out an object OR Synonym

Script to query db growth history using backup history this is accurate as long as there's no compression involved.

Find what profile values are set for a particular user

08 September, 2012   

SQL query to know employees where city is null

08 September, 2012   

SQL query to know total number of employee on each department.

MS SQL triggers for automatic Create and LastModified Dates