Click here to Skip to main content
15,942,710 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have created view in sql server 2005.

SQL
create view TestView
as
select Id,StuName from Student


I can also use sql query in my code as
SQL
select Id, StuName from Student

instead of
SQL
select * from TestView

in which i have mentioned
SQL
select Id,StuName from Student


what is the difference between these two.

What is the use for Creating View
Posted
Updated 27-Sep-10 7:00am
v2

1 solution

Here is an insight into views;
http://www.craigsmullins.com/cnr_0299b.htm[^]

All your answers on why you should want to use them are in there.

Also, you should never query Select * unless you absolutely must, it has the potential to crash you app all to easily if there are millions of record in the source table, it also returns all the columns, and you maybe only need a couple of them, e.g. Id and StuName.
 
Share this answer
 
Comments
navi.s 30-Sep-10 20:10pm    
I know how to use select query.
i just put here select *,i know where there are lot of columns and if you need two columns,then you write couple of them in select statement.

Question is about View in sql Server 2005.
But your link can't able to explain me in detail.
can you give example to explain it.
DaveAuld 2-Oct-10 8:31am    
What needs explaining? The article gives you valid reasons when to use views, what limitations exist when using views etc. just read it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900