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.

1 comment:

Anonymous said...

я вот что скажу: прелестно. а82ч