1

Recently I am working with SQL language. I found two ways of declaring temporary table variables(starting with @). My question is:

Is there any difference between them?

DECLARE
    @variable1 [int],
    @variable2 int
  • This has nothing to see with tables. Both declarations means the same. – McNets Jun 26 '17 at 15:01
  • no, there is no difference have a look here: https://stackoverflow.com/questions/52898/what-is-the-use-of-the-square-brackets-in-sql-statements – Esteban P. Jun 26 '17 at 15:02
  • 2
    Possible duplicate of [What is the use of the square brackets \[\] in sql statements?](https://stackoverflow.com/questions/52898/what-is-the-use-of-the-square-brackets-in-sql-statements) – Esteban P. Jun 26 '17 at 15:03
  • 1
    There are many flavours of SQL. Tag your question with the system you are using ([tag:sql-server], it seems) – axiac Jun 26 '17 at 15:04
  • 1
    Outside of micosoft (and possibly Sybase) the `[]` are a syntax error. – joop Jun 26 '17 at 15:06

2 Answers2

1

There is no difference in this instance. However, the square brackets are used as delimiters if you have special characters that need identifying - for example if you name a column "First Name", you'll need square brackets to escape the space character.

rageandqq
  • 2,221
  • 18
  • 24
0

Nope those are the same. Typing it with the brackets is just extra keystrokes.

Collatrl
  • 171
  • 1
  • 13