• Hugo Kornelis (12/26/2012)


    SanDroid (12/26/2012)


    Hugo, Great question that realy made me think.

    However part of your explination seems incomplete or missleading.

    If statements and other control flow language create new batches, and that is why they can not be used in the definition of a view. Anything that creates more than one batch can not be used in the definition of a view.

    Hi SanDroid,

    Thank you for your kind words! (and thank you to other people who wrote kind words as well).

    I don't really understand the point you raise about the incomplete explanation. What you say is right - you cannot use control flow in a view definition; in fact, a view definition has to be a single SELECT. But how does that relate to the question and explanation? Can you clarify (maybe with some sample code to illustrate the issue)?

    :ermm: You do not know the difference between creating a new TSQL batch and a control flow function? 😛 With all the ";" followed by a "go" in your example code I guess that is no suprise. Here is some infomration online you can read...

    http://www.sqlservergeeks.com/blogs/piyush.bajaj.2007/sql-server-bi/280/sql-server-%E2%80%93-transact-sql-batches

    Also your red colored quote above is totaly wrong. More than one select can be in any View, but only one batch. Please tell me you do not need a code example to know the differnce between one select statement and one TSQL batch... :hehe:

    Don't bait me... I'm no fish... :