MS SQL views

Discussion in 'Databases' started by Jamie18, Jul 3, 2008.

  1. #1
    i'm creating a search mechanism for my app...

    in this there are several select boxes, checkboxes, etc for filtering.. and several more select boxes to choose the desired fields to return..

    i'm running into a bit of a problem.. i've built the query dynamically so that it forms joins based on the fields the user wants to view.. however if the user wants to return every possible field it gets to the point that there are too many joins and the query runs very slowly...

    so i'm thinking that creating a view with all tables already joined may be the answer? however, i'm not too familiar with working with views..

    if i have a view called 'phone view'

    and i run something like this
    select *
    from [phone view]
    where something like 'somethingelse'

    does that mean the view is calculated during this process?..... or how dynamic are the views? is it always the most current information from my other tables? or is it some kind of static snapshot?

    basically i just want to know if it's worth my while to switch the code over

    thanks for any help
     
    Jamie18, Jul 3, 2008 IP
  2. Jamie18

    Jamie18 Peon

    Messages:
    201
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    ps. what i'm worried about is if i switch to a view and there is no real performance increase from the previous way... i'm sure it would run in at least the same time if all fields are chosen.. but what if only a few fields are chosen--- which in my original dynamic query would only require a couple joins
     
    Jamie18, Jul 3, 2008 IP