• Sean Lange (10/18/2013)


    patrickmcginnis59 10839 (10/18/2013)


    T.Ashish (10/1/2013)


    Hi all,

    I consider CURSOR and TABLE as data types but some one has argued that these are database objects.

    Can you please share your views on the same !!

    Thanks.

    I agree with your terminology.

    For example,

    DECLARE some_name CURSOR FOR select_statement

    in my mind would create a variable called 'some_name' as type cursor, same with tables, with individual named cursors and tables as instances or "database objects" having those types.

    Not sure how excited I would be about having to convince someone about that who thinks otherwise, but its a bit satisfying for a language nerd like myself.

    **cough**CURSOR**cough** is listed as a datatype (other). This to me is a bit strange. Generally datatypes can define either a column in a table or a variable. You can't have a column with a type of cursor. That makes no sense, yet it is a datatype of sorts.

    Its more of a language thing, I wouldn't necessarily be stuck on a datatype having to apply only to something that fits in a column, for instance, while we don't necessarily think of a procedure as being a datatype, in reality, a procedure name would actually point to a bunch of text (and all the compilation constructs), so even here I'd consider a procedure as a type also, with procedure definitions being instances of that type, but really, thats probably just me talking about programming languages and implementations, and is probably not something that has great practical value otherwise. Heck, for that matter, a real SQL server implementer would probably shoot my random musings full of holes.

    http://technet.microsoft.com/en-us/library/ms187752.aspx

    With the exception of cursor and table. You can have a column with any of the other datatypes.

    For a table, it depends. If it is a permanent or temp table then I would argue in those circumstances that is a database and NOT a datatype. However, we can have table variables. I would say that the type of that variable is a table. In other words a table can be either in some situations.

    It depends on how picky we are I guess, after all we're humans attaching names to bits and bytes. For example, I like to think that "table" is just one type, and according to the attributes of given instances of that type (whether a variable or non variable table), we can then determine what operations can be applied to instances of that type, for example, table variables are of type TABLE (in my view of things), but the INSTANCE of that type has particular attributes that limit us as to what operations we can do (like expect the data held by the instance to hang around, roll back from transactions, etc).

    An interesting question that can have a number of interpretations and the explanation can be as challenging as the question itself. 😎

    I suspect the REAL answer is buried deep inside a Microsoft engineering document 😀