[] brackets in sql statements

前端 未结 8 2424
深忆病人
深忆病人 2020-11-28 12:24

What do the brackets do in a sql statement?

For example, in the statement:

insert into table1 ([columnname1], columnname2) values (val1, val2)

相关标签:
8条回答
  • 2020-11-28 13:21

    The [] marks the delimitation of a identifier, so if you have a column whose name contains spaces like Order Qty you need to enclose it with [] like:

    select [Order qty] from [Client sales]
    

    They are also to escape reserved keywords used as identifiers

    0 讨论(0)
  • 2020-11-28 13:22

    When having table names or filenames with spaces or dashes (-) etc... you can receive "Systax error in FROM clause". Use [] brackets to solve this.

    See: https://msdn.microsoft.com/en-us/library/ms175874.aspx

    0 讨论(0)
提交回复
热议问题