Saturday, January 23, 2016

SQL Server access Previous / Next rows and first / last row from partitioned resultset

From SQL Server 2012, new built-in analytic functions are introduced, using that we can easily access subsequent/previous row in the same result set without the use of a self-join and first/last value in an ordered set of values.

In this post, let us see some examples for LEAD(), LAG(), FIRST_VALUE() and LAST_VALUE()

Saturday, January 16, 2016

SQL Server - Example for invoking sql file through SQLCMD

SQLCMD utility lets us execute Transact-SQL statements, Stored procedures, and other script files at the command prompt,
in SSMS Query Editor in SQLCMD mode,
in a Windows script file or
in an operating system (Cmd.exe) job step of a SQL Server Agent job.

In this post, let us see an example for invoking sql file through SQLCMD

Thursday, January 14, 2016

SSRS Exporting reports to different file formats

Till SQL Server 2012 below are the supported file formats for exporting SSRS reports :

From 2016,