Short Variables

  • Comments posted to this topic are about the item Short Variables

  • Steve Jones - SSC Editor - Wednesday, November 28, 2018 9:42 PM

    Comments posted to this topic are about the item Short Variables

    Thanks for this question Steve. It is clear that the shortest write is @ but I chose answer # 4, because the sysname data type is used for variables.
    See DOCS in Database Identifiers, or the sysname paragraph in Using Special Data Types and Remarks in nchar and nvarchar (Transact-SQL).
    You can verify information about SYSNAME with:
    EXEC sp_help SYSNAME;
    GO

  • Not sure where sysname comes in here with "all variables", but am I missing something?

  • Steve Jones - SSC Editor - Thursday, November 29, 2018 11:28 AM

    Not sure where sysname comes in here with "all variables", but am I missing something?

    I'm sorry, I mistaken it with the space needed for the names of the variables...:crazy:

  • My Google-fu is failing me but I thought I had read that using @ or @@ alone had been deprecated by Microsoft.

  • Haven't seen anything on that. It's not on the @(local variable) page that I see.

    Then again, I don't think it's a good idea. Just an interesting question

  • bah, this bit me.. I also thought i read that the use of @ or @@ was deprecated, but cannot remember where.
    Really interesting question, thanks Steve
    IMHO, to do that, though, is just an incident waiting to happen - will also make support a nightmare...

    ____________________________________________
    Space, the final frontier? not any more...
    All limits henceforth are self-imposed.
    “libera tute vulgaris ex”

  • Stewart "Arturius" Campbell - Thursday, November 29, 2018 10:11 PM

    bah, this bit me.. I also thought i read that the use of @ or @@ was deprecated, but cannot remember where.
    Really interesting question, thanks Steve
    IMHO, to do that, though, is just an incident waiting to happen - will also make support a nightmare...

    This got me too, I thought the question referred to the fact that all variables are initialized as null unless a value is provided.
    As far as deprecation is concerned Stewart's (and Lynn's) memory serves them well, one such reference is here (under the Transact-SQL section), although arguably this applies from SQL2016.

    ...

  • If they haven't deprecated it then they definitely should!!

  • allinadazework - Friday, November 30, 2018 2:53 AM

    If they haven't deprecated it then they definitely should!!

    According to MS they have!! See the link provided.

    ...

  • Stewart "Arturius" Campbell - Thursday, November 29, 2018 10:11 PM

    bah, this bit me.. I also thought i read that the use of @ or @@ was deprecated, but cannot remember where.
    Really interesting question, thanks Steve
    IMHO, to do that, though, is just an incident waiting to happen - will also make support a nightmare...

    Hi Stewart
    Maybe it could be here: SQL Server, Deprecated Features Object

  • Lynn Pettis - Thursday, November 29, 2018 3:58 PM

    My Google-fu is failing me but I thought I had read that using @ or @@ alone had been deprecated by Microsoft.

    You are correct. Doing this has been deprecated starting with the release of SQL Server 2008. You can find it mentioned on the following archived documentation page for "Deprecated Database Engine Features in SQL Server 2008" under "Features Not Supported in a Future Version of SQL Server". Just do a "find" for "@@". (and in case anyone was wondering, I did check the 2005 documentation and there is no mention of this)

    You can also create a local temp table with a name of just "#", or even a global temporary table named "##". Not that you should, but you can. Also deprecated as of SQL Server 2008.

    But, even with both being deprecated, I don't see this "ability" being fully removed anytime soon.

    For the complete list of rules that govern identifier names (including variables), please see my post:

    Completely Complete List of Rules for T-SQL Identifiers

    Take care, Solomon..

    SQL#https://SQLsharp.com/ ( SQLCLR library ofover 340 Functions and Procedures)
    Sql Quantum Lifthttps://SqlQuantumLift.com/ ( company )
    Sql Quantum Leaphttps://SqlQuantumLeap.com/ ( blog )
    Info sitesCollations     •     Module Signing     •     SQLCLR

  • George Vobr - Friday, November 30, 2018 6:04 AM

    Stewart "Arturius" Campbell - Thursday, November 29, 2018 10:11 PM

    bah, this bit me.. I also thought i read that the use of @ or @@ was deprecated, but cannot remember where.
    Really interesting question, thanks Steve
    IMHO, to do that, though, is just an incident waiting to happen - will also make support a nightmare...

    Hi Stewart
    Maybe it could be here: SQL Server, Deprecated Features Object

    That's the one, thanks George.

    ____________________________________________
    Space, the final frontier? not any more...
    All limits henceforth are self-imposed.
    “libera tute vulgaris ex”

  • Solomon Rutzky - Wednesday, December 5, 2018 9:23 AM

    But, even with both being deprecated, I don't see this "ability" being fully removed anytime soon.

    According to https://docs.microsoft.com/en-us/sql/database-engine/deprecated-database-engine-features-in-sql-server-2016?view=sql-server-2017

    When a feature is marked deprecated, it means:

    • The feature is in maintenance mode only. No new changes will be done, including those related to inter-operability with new features.
    • We strive not to remove a deprecated feature from future releases to make upgrades easier. However, under rare situations, we may choose to permanently remove the feature from SQL Server if it limits future innovations.
    • For new development work, we do not recommend using deprecated features.

  • Toreador - Thursday, December 6, 2018 3:43 AM

    Solomon Rutzky - Wednesday, December 5, 2018 9:23 AM

    But, even with both being deprecated, I don't see this "ability" being fully removed anytime soon.

    According to https://docs.microsoft.com/en-us/sql/database-engine/deprecated-database-engine-features-in-sql-server-2016?view=sql-server-2017

    When a feature is marked deprecated, it means:

    • The feature is in maintenance mode only. No new changes will be done, including those related to inter-operability with new features.
    • We strive not to remove a deprecated feature from future releases to make upgrades easier. However, under rare situations, we may choose to permanently remove the feature from SQL Server if it limits future innovations.
    • For new development work, we do not recommend using deprecated features.

    Interesting. I guess I was going by the wording on the older pages, such as what was there back on the 2008 page (the one linked in my post above):

    (at the top of the page -- emphasis mine)

    This topic describes the deprecated SQL Server Database Engine features that are still available in SQL Server 2008. These features are scheduled to be removed in a future release of SQL Server.

    (under "Features Not Supported in a Future Version of SQL Server" -- emphasis mine)

    The following SQL Server Database Engine features are supported in the next version of SQL Server, but will be removed in a later version. The specific version of SQL Server has not been determined.

    Thanks for pointing this out. Take care, Solomon...

    SQL#https://SQLsharp.com/ ( SQLCLR library ofover 340 Functions and Procedures)
    Sql Quantum Lifthttps://SqlQuantumLift.com/ ( company )
    Sql Quantum Leaphttps://SqlQuantumLeap.com/ ( blog )
    Info sitesCollations     •     Module Signing     •     SQLCLR

Viewing 15 posts - 1 through 15 (of 16 total)

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