User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 423,880 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,185 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser: Programming Forums
Views: 11344 | Replies: 2
Reply
Join Date: Jun 2005
Posts: 1
Reputation: tyger is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
tyger tyger is offline Offline
Newbie Poster

How does views work in MS SQL

  #1  
Jun 1st, 2005
I have been told that views in MS SQL aren’t very good to use. Let’s say that you have a view X with 2 columns Car and Color that looks like this

Car Color
----- ------
Alfa Yellow
Volvo Yellow
Volvo Blue
Ford Yellow
Ford Blue

If you then run the following statement to get all Fords that are yellow:

select * from X where Car=’Ford’ and Color=’Yellow’

I have been told that when you run this statement the database will return all rows where the Car is Ford and all rows where the Color is Yellow and then the client filter out the Fords that are yellow, that is:

This is returned to the client side:

Alfa Yellow
Volvo Yellow
Ford Yellow
Ford Blue

Then the filtering is done on the client side so I only get the Ford that is yellow. I was told that I shouldn’t use the views cause of this.

I think this sounds very strange and can’t believe that views work in this way. I thought all processing was done in the database and then only returns what I want, the yellow Ford.

Could anyone clarify this for me? Give me some links where I can read about this?

Thanks in advance
Markus
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2005
Location: Texas
Posts: 120
Reputation: jwshepherd is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 5
jwshepherd's Avatar
jwshepherd jwshepherd is offline Offline
Junior Poster

Re: How does views work in MS SQL

  #2  
Jun 16th, 2005
Views are basically a few tables group together by a server side query.
select * from X where Car=’Ford’ and Color=’Yellow’

would return only Ford = Yellow
select * from X where Car=’Ford’ or  Color=’Yellow’

would return
Alfa Yellow
Volvo Yellow
Ford Yellow
Ford Blue

You can create a view by creating a sql query on the server, since it runs on the server, it is usually fasterthan the client requesting x number of tables and y pieces from each one.

I believe the information you recieved may be a little inaccurate
Reply With Quote  
Join Date: Jun 2005
Location: Nothamptonshire
Posts: 27
Reputation: pclfw is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
pclfw pclfw is offline Offline
Light Poster

Re: How does views work in MS SQL

  #3  
Jun 25th, 2005
Views work VERY well in MS SQL and can do some very detailed and complex discrimination and manipulation. Have a good look at Books-On-Line and play with them for a while.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MS SQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the MS SQL Forum

All times are GMT -4. The time now is 4:38 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC