I have never seen an insert statement with -= tablename in place of values

  • We have a third part software and looking at some of their SQL we found this

    INSERT INTO tblSoftware ( Inventory , Software, [Name] , Manufacturer , [Language] , [ Version ] , OSType , [Executable] , ExecutablePath , ExecutablePathReversed , IOS , Reg , TS , VT ) – = inv.tblSoftware

    I have never see -=Table what are they doing?

     

  • lee.hopkins wrote:

    We have a third part software and looking at some of their SQL we found this

    INSERT INTO tblSoftware ( Inventory , Software, [Name] , Manufacturer , [Language] , [ Version ] , OSType , [Executable] , ExecutablePath , ExecutablePathReversed , IOS , Reg , TS , VT ) – = inv.tblSoftware

    I have never see -=Table what are they doing?

    To the best of my knowledge, the -= in SQL Server is known as a "Compound Operator" and you can read about those at the following link... I used to use += a fair bit.

    https://learn.microsoft.com/en-us/sql/t-sql/language-elements/compound-operators-transact-sql

    The thing is, I've not seen it in an INSERT statement before and certainly not in the context of a Table.  It does, in fact, produce an error marking in SQL Server.

    Could it be that they've simple found a way to mask a part of the code that's actually being executed or perhaps you sampled their code incorrectly?  It might help if we saw the proverbial "rest of the story" in the code that follows that insert.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • I think it is a typo, they probably meant to type '-- = inv.tblSoftware'

    Which would mean that inv.tblSoftware is just a comment for clarity, describing something about the insert operation.

  • Jonathan AC Roberts wrote:

    I think it is a typo, they probably meant to type '-- = inv.tblSoftware'

    Which would mean that inv.tblSoftware is just a comment for clarity, describing something about the insert operation.

    Agreed on that.  Even things like MS Word will sometimes convert two shorter dashes to a single "m-dash".

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • I think it's actually an en dash, not that it makes any difference to the point you're making!

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • Jeff Moden wrote:

    Jonathan AC Roberts wrote:

    I think it is a typo, they probably meant to type '-- = inv.tblSoftware'

    Which would mean that inv.tblSoftware is just a comment for clarity, describing something about the insert operation.

    Agreed on that.  Even things like MS Word will sometimes convert two shorter dashes to a single "m-dash".

    I've had it happen with MS OneNote which looks like a text editor.

  • Thanks for the response, I bet your correct -- comment

Viewing 7 posts - 1 through 6 (of 6 total)

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