Saturday, June 28, 2008

Creating views in SQL server 2005

After creating tables in SQl server 2005,its time to create views.The Views are reprsentations of parts of the table generated by the datbase based on a usedefined query. These are used primarily to view only required data from a large table.
Expand the database in which the view has to be created and right click on the Views.Select the create new View option and you will be presented with the above screen with the list of tables that are present in the database.We select the emp_table and click on add and then close this window.

After the above window is closed the below window appears. It has four different parts. The top most part contains the list of columns in the emp_table which can be added to the view.The next part provides various options to customise the view. The columns to be included and the alias name that have to be given to those columns in the view, the table in which the column is present, the way the column has to be sorted in the view, the sort order to be followed in the
view, any filters to be used in the view and other options such as the use of aggregate functions etc.



The third part shows the actuall query that is to be run. Once we have choosen the required query either by directly editing the query or using the interface provided, the query can be tested by clciking on the execute button that is highlighted in the above window.The output of the query(either the view or the error message)appears in the fourth part.Once the view of your choice is ready the view can be saved by chossing the save view option under the file menu.

Sunday, June 22, 2008

Robin without a hood is not robinhood

The robin was hoping around on the fence.

More and more birds are flocking to the garden with growing foliage.

Robin must not be confused with robinhood who actaully is from nottingham in england and is rather popular in literature.

Friday, June 20, 2008

46893711600000 - what does this number signify?

46893711600000 is the number of seconds since "00:00:00 January 1, 1970." that it will take to get unlimited storage space on gmail ...:) If the javascript in the gmail login page is to be belived.

So we will get unlimited storage space in gmail at 01-02-3456 07:00:00 hours.
However, the year 2038 problem if not fixed in future versions of the browsers for Javascript the program will just fail. If you just google for 46893711600000 you will be surprised by the number of results you will get though.

Restoring database backup in SQL server 2005

We have seen backing up a database in SQL server 2005, the backup can be restored to get the database to the state in which it was when the backup was taken. The steps are as follows:
  1. Expand the database tab to display all the databases running in SQL server.

  2. Right click the database that has to be backed up and select the "Tasks" option.

  3. In the "Tasks" option the Restore database option has to be selected.

The below screen comes up after selecting the option.



The database that has to be restored is to be slected in the to database menu.The time upto which the restoration has to be done can be selected based on the type of backup that was taken earlier.

The source and location from which the backup data can be obtained has to be specified. The options tab provides various Restore options and Recovery states which are selected based on the needs of a particular restore operation.

Creating database backup in SQL server 2005

The SQL server 205 databases can be backed up either on to the Disk or Tape. In this post we will look at backing a databse to the Disk.The steps to follow are as follows:


  1. Expand the database tab to display all the databases running in SQL server.

  2. Right click the database that has to be backed up and select the "Tasks" option.

  3. In the "Tasks" option the Backup databse option has to be selected.

The below screen comes up after selecting the option.


The database that has to be backed up is to be slected under source and the recovery model of the selected database is automatically filled in.
The backup types that can be selected for a particular recovery model are availbale in Backup type option.
The component that has to be selected(database in this case) has to be choosen.Note that file group backups can also be taken.
The Backup set details such as Name of the backup set, its description, the expiry date of the backup set and destination of backup set are to be selected. The contents button will show the various components of the database that are being backed up in the particular database.

when a backup already exsists the options tab can be used to specify wehter the earlier backup has to be overwritten or apended to.Reliability checks such as Verification of the baclup when finished and performing checksum before writing to the media can also be specified to ensure the reilability of the backup.