Difference between Script and View

  • What is the difference between a Script and a View?

    Thanks.

     

     

     

  • minor differences: a VIEW is a saved SELECT statement(script), but it has some additional constraints, like all column names in the SELECT must be unique (can't do SELECT ID,ID,* FROM SOMETABLE, gotta use ID AS ID1, ID as ID2, etc) and may not include an ORDER BY unless TOP is used.

    a SELECT statement, if run once, will cause SQL Server to create an execution plan so that if it is called again, SQL server will already have a plan to get the data again faster. that plan will expire after a while if it does not get called frequently.

    A view's plan is compiled and stays in place.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply