T-SQL Views:A view is not a physical table it is a virtual table, but it also has the columns and information same as like various actual tables. Usually, the view is the structure of the table in the format of the SQL query which is predefined. The view can be created using the table of all rows or selected rows of a table. Based on the written query view can be formed from a single table or many tables.Following are the advantages of views:Views can be used to do not allow users to access the particular rows in the table, for instance, we can let an employee see the records of his work-related hours when accessing table.Views are used in SQL Server to provide the security. Generally to block the users from seeing particular tuple or columns views are used. Views show only the information which is represented in the query, so it displays the information which we selected to create a view.View also used to hide the complexity of data, because view joins the more tables and will provide it to the user as one object.We can create, alter, and drop the views:Below is an example for creating simple view:Example:CREATE VIEW View_ProductionASSELECT ProductID, Name FROM Production.Product;This is a query to see the viewSelect * from View_Production;Stored Procedures:Stored procedures are nothing but a group of SQL statements. There are multiple systems provided stored procedures are available in MS SQL server, but still, the user can generate their own stored procedures (McEvoy, 2009). Stored procedures take input parameters. It also contains statements of programming. There are many advantages of creating a stored procedure. Below are some of them.Stored procedures can be created once they can be called many times same as like function in programming languages.In stored procedures execution of the code is faster and network traffic also decreased.Database security can present via stored procedures; you can allow users to execute the stored procedures without authorizing to access the actual table.Example:Stored procedure with one parameterUSE AdventureWorks2012GOCREATE PROCEDURE GetFname @Firstname varchar(50)ASSELECT *FROM Person.PersonWHERE Firstname = @FirstnameGOThe following query is used to get the results of the above stored procedure.EXEC GetFname @Firstname = ‘Gail’;

x

Hi!
I'm Cody!

Would you like to get a custom essay? How about receiving a customized one?

Check it out