Skip to main content

Posts

Showing posts from July, 2018

Purpose of using Cursors in SQL server

A database cursor is similar to the cursor on a word processor screen. As you press the down arrow key, the cursor scrolls down through the text one line at a time. Pressing the Up Arrow key scrolls your cursor up one line at a time. Pressing other keys such as Page Up and Page Down results in a leap of several lines in  either direction. Database cursors operate in the same way. Database cursors enable you to select a group of data, scroll through the group of records(often called a recordset), and example each individual line of data as the cursor points to it. You can use a combination of local variables and a cursor to individually examine each record and perform any external operations needed before moving on to the next record.yo One other common use of cursors is to save a query's results for later use. A cursor's result set is created from the result set of a SELECT query. If your application or procedure requires the repeated use of a set of records, it is fast...

Exploring Views in SQL Server

SQL Views A view is often referred to as a virtual table, which means that a view looks like a table and is referenced like a table. However, views do not contain data like tables do. The only storage required for a view is the storage to maintain the definition of the view. Views are created by using the CREATE VIEW statement. After the view has been created , you can use the following SQL commands to refer to the view: SELECT INSERT UPDATE DELETE Syntax: The syntax for the CREATE VIEW statement is, CREATE VIEW <view_name> [(column1,column2...)] AS SELECT <column_names> FROM <table_name> Examples: The example tables are given below Table1 :  Bills NAME AMOUNT ACCOUNT_ID Software Company  $75 1 Phone Company $25 2 Power Company $250 2 Record Club $35 3 Exploring a Simple View Input1 : CREATE VIEW DEPTS AS SELECT * FROM BILLS; Input2 : SELECT * FROM DEBTS; Results Output1: Out...

Effective ways to use SQL subquery

A subquery is a query whose results are passed as the argument for another query. Syntax: select * from table1 where table1.column1 = ( select othercolumn1 from table2 where othercolumn1 = value ); Examples The example tables are given below Table1 : Products PARTNUM NAME PRICE 101 Chain Saw $80 102 Circular Saw $120 103 Drill $240 104 Hammer $100 Table2 :  Orders ORDERED DATE PARTNUM QUANTITY REMARKS 2018-07-27 101 2 PAID 2018-07-28 102 1 PAID 2018-07-29 101 3 PAID 2018-07-30 103 4 PAID Example 1: The tables share a common field called PARTNUM . Suppose you didn't know the PARTNUM, but instead wanted to work the Name of the Product. Using a subquery, you could type this: select * from Orders where PARTNUM = ( select...

How to Create Scenario Manager in Excel-2016?

How to Create Sparklines in Excel-2016?

How to Create Outlines in Excel-2016?