• 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.

    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.

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

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/