Blog

Using PIVOT and UNPIVOT

You can use the PIVOT and UNPIVOT relational operators to manipulate a table-valued expression into another table. PIVOT rotates a table-valued expression by turning the unique values from one column in the expression into multiple columns in the output, and performs aggregations where necessary on any remaining column values that are desired in the final output. UNPIVOT performs the opposite operation to PIVOT by rotating columns of a table-valued expression into column values. Every PIVOT query involves an aggregation of some type.

By Admin

Summarizing Data with CUBE and ROLLUP

Is an aggregate function that causes an additional column to be output with a value of 1 when the row is added by either the CUBE or ROLLUP operator, or 0 when the row is not the result of CUBE or ROLLUP?

By Admin

VIEWS in SQL Server

The View is a saved SQL statement and referred as a virtual table. When you create a view, Microsoft SQL Server stores only metadata information about the view, describing the object, its columns, security, dependencies, and so on.

By Admin

Exception Handling in Sql Server

Starting in SQL Server 2005, the exception handling has been very similar to the exception handling in c++ and c#. SQL Server 2005 introduced the Try and Catch blocks. You can place all your T-SQL statements in the TRY block. If an error occurred in any T-SQL statements within the TRY block, then the control will jump to the nearest CATCH block. In the CATCH block you can do any extra processing (e.g., rollback any remaining transactions) and if you want to re-throw the error, then you can use RAISERROR command. But if there was no error in the TRY block, the CATCH block will be skipped.

By Admin

SQL Injection

It is a type of attacking technique by changing the SQL code in your website. If your web application was not developed carefully and wisely, then there is a chance that attackers can do SQL Injections and mess up your database. They may alter the SQL code and steal your vital information from the database. Not only getting information from your database, they can also delete and modify information or modify the structure of your database.

By Admin